博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
用windows live writer写的
阅读量:6690 次
发布时间:2019-06-25

本文共 5698 字,大约阅读时间需要 18 分钟。

关于配置

发布配置

http://你的blog地址/metawebblog.axd

 

#region Usingusing System;using System.Web;using System.Collections.Generic;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.HtmlControls;using BlogEngine.Core;#endregionpublic partial class archive : BlogEngine.Core.Web.Controls.BlogBasePage{    ///     /// Handles the Load event of the Page control.    ///     /// The source of the event.    /// The 
instance containing the event data. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack && !IsCallback) { CreateMenu(); CreateArchive(); AddTotals(); } Page.Title = Server.HtmlEncode(Resources.labels.archive); base.AddMetaTag("description", Resources.labels.archive + " | " + BlogSettings.Instance.Name); } /// /// Creates the category top menu. /// private void CreateMenu() { foreach (Category cat in Category.Categories) { AddCategoryToMenu(cat.Title); } } private void AddCategoryToMenu(string title) { HtmlAnchor a = new HtmlAnchor(); a.InnerHtml = Server.HtmlEncode(title); a.HRef = "#" + Utils.RemoveIllegalCharacters(title); a.Attributes.Add("rel", "directory"); HtmlGenericControl li = new HtmlGenericControl("li"); li.Controls.Add(a); ulMenu.Controls.Add(li); } /// /// Sorts the categories. /// /// The categories. private SortedDictionary
SortCategories(Dictionary
categories) { SortedDictionary
dic = new SortedDictionary
(); foreach (Category cat in Category.Categories) { dic.Add(cat.Title, cat.Id); } return dic; } private void CreateArchive() { foreach (Category cat in Category.Categories) { string name = cat.Title; List
list = Post.GetPostsByCategory(cat.Id).FindAll(delegate(Post p) { return p.IsVisible; }); HtmlGenericControl h2 = CreateRowHeader(cat.Id, name, list.Count); phArchive.Controls.Add(h2); HtmlTable table = CreateTable(name); foreach (Post post in list) { CreateTableRow(table, post); } phArchive.Controls.Add(table); } List
noCatList = Post.Posts.FindAll(delegate(Post p) { return p.Categories.Count == 0; }); if (noCatList.Count > 0) { string name = Resources.labels.uncategorized; HtmlGenericControl h2 = CreateRowHeader(Guid.NewGuid(), name, noCatList.Count); phArchive.Controls.Add(h2); HtmlTable table = CreateTable(name); foreach (Post post in noCatList) { CreateTableRow(table, post); } phArchive.Controls.Add(table); AddCategoryToMenu(name); } } private static HtmlGenericControl CreateRowHeader(Guid id, string name, int count) { HtmlAnchor feed = new HtmlAnchor(); feed.HRef = Utils.RelativeWebRoot + "category/syndication.axd?category=" + id.ToString(); HtmlImage img = new HtmlImage(); img.Src = Utils.RelativeWebRoot + "pics/rssbutton.gif"; img.Alt = "RSS"; feed.Controls.Add(img); HtmlGenericControl h2 = new HtmlGenericControl("h2"); h2.Attributes["id"] = Utils.RemoveIllegalCharacters(name); h2.Controls.Add(feed); Control header = new LiteralControl(name + " (" + count + ")"); h2.Controls.Add(header); return h2; } private static void CreateTableRow(HtmlTable table, Post post) { HtmlTableRow row = new HtmlTableRow(); HtmlTableCell date = new HtmlTableCell(); date.InnerHtml = post.DateCreated.ToString("yyyy-MM-dd"); date.Attributes.Add("class", "date"); row.Cells.Add(date); HtmlTableCell title = new HtmlTableCell(); title.InnerHtml = string.Format("
{1}", post.RelativeLink, post.Title); title.Attributes.Add("class", "title"); row.Cells.Add(title); if (BlogSettings.Instance.IsCommentsEnabled) { HtmlTableCell comments = new HtmlTableCell(); comments.InnerHtml = post.ApprovedComments.Count.ToString(); comments.Attributes.Add("class", "comments"); row.Cells.Add(comments); } if (BlogSettings.Instance.EnableRating) { HtmlTableCell rating = new HtmlTableCell(); rating.InnerHtml = post.Raters == 0 ? "None" : Math.Round(post.Rating, 1).ToString(); rating.Attributes.Add("class", "rating"); row.Cells.Add(rating); } table.Rows.Add(row); } private HtmlTable CreateTable(string name) { HtmlTable table = new HtmlTable(); table.Attributes.Add("summary", name); HtmlTableRow header = new HtmlTableRow(); HtmlTableCell date = new HtmlTableCell("th"); date.InnerHtml = base.Translate("date"); header.Cells.Add(date); HtmlTableCell title = new HtmlTableCell("th"); title.InnerHtml = base.Translate("title"); header.Cells.Add(title); if (BlogSettings.Instance.IsCommentsEnabled) { HtmlTableCell comments = new HtmlTableCell("th"); comments.InnerHtml = base.Translate("comments"); comments.Attributes.Add("class", "comments"); header.Cells.Add(comments); } if (BlogSettings.Instance.EnableRating) { HtmlTableCell rating = new HtmlTableCell("th"); rating.InnerHtml = base.Translate("rating"); rating.Attributes.Add("class", "rating"); header.Cells.Add(rating); } table.Rows.Add(header); return table; } private void AddTotals() { int comments = 0; int raters = 0; foreach (Post post in Post.Posts) { comments += post.ApprovedComments.Count; raters += post.Raters; } ltPosts.Text = Post.Posts.Count + " " + Resources.labels.posts.ToLowerInvariant(); if (BlogSettings.Instance.IsCommentsEnabled) ltComments.Text = comments + " " + Resources.labels.comments.ToLowerInvariant(); if (BlogSettings.Instance.EnableRating) ltRaters.Text = raters + " " + Resources.labels.raters.ToLowerInvariant(); }}
转载请注明出处[ ] 
作者赞赏
 
刚做的招标网:  请大家多意见
本文转自Sam Lin博客博客园博客,原文链接:http://www.cnblogs.com/samlin/archive/2009/07/29/1533980.html,如需转载请自行联系原作者
你可能感兴趣的文章
Linux CPU
查看>>
Linux/Centos ntp时间同步,联网情况和无网情况配置
查看>>
初级网络运维工程师比赛题目
查看>>
跨交换机实现vlan实验报告
查看>>
jquery easyui滚动条部分设置介绍
查看>>
cannot find -lxxx问题
查看>>
预防云端开源项目打包 Redis Labs再更改模块
查看>>
超惊人!去年发生的身分外泄安全事件是2017的4倍
查看>>
oracle sqlplus免安装的配置instantclient-basiclite
查看>>
Java开发GUI之选择列表
查看>>
一、分布式商城架构逻辑图
查看>>
机器人是如何完成避障的?机器人避障解决方案解读
查看>>
通过错误堆栈信息和源码分析错误来源
查看>>
C和C++ 读写文件速度问题
查看>>
layer.mobile 弹出框插件(2.0版)
查看>>
IDC服务品质协议范本留存
查看>>
在 overlay 中运行容器 - 每天5分钟玩转 Docker 容器技术(51)
查看>>
前端MVC框架 EmberJS总结
查看>>
LVS
查看>>
搭建高可用mongodb集群(三)—— 深入副本集内部机制
查看>>