📄 aggregatersswriter.cs
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
// Copyright (c) Telligent Systems Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
using System.Collections;
using CommunityServer.Components;
namespace CommunityServer.Galleries.Components
{
/// <summary>
/// Summary description for AggregateRssWriter.
/// </summary>
public class AggregateRssWriter : BaseRssWriter
{
protected Group CurrentGroup = null;
protected bool HasGroup
{
get
{
return CurrentGroup != null;
}
}
public AggregateRssWriter(ArrayList posts, Group group, string baseUrl):base(posts,null, baseUrl)
{
CurrentGroup = group;
}
protected override string Title
{
get
{
return CSContext.Current.SiteSettings.SiteName;
}
}
protected override string EnclosureUrl(PostAttachmentMetaData pa)
{
if(pa.IsRemote)
return pa.FileName;
Gallery s = Galleries.GetGallery(pa.SectionID);
return this.BaseUrl + GalleryUrls.Instance().AttachmentUrl(s,pa);
}
protected override void PostBody(Post p)
{
GalleryPost gp = p as GalleryPost;
if(gp == null)
base.PostBody(p);
else
{
string desc = null;
if(gp.SyndicateExcerpt)
{
if(gp.HasExcerpt)
{
desc = gp.Excerpt;
}
else
{
desc = Formatter.RemoveHtml(p.RenderedBody(PostTarget.Syndication),500) ;
}
desc = string.Format("{0}...(<a href=\"{1}\">read more</a>)",desc,FormatUrl(BuildLink(p)));
}
else
{
desc = p.RenderedBody(PostTarget.Syndication);
}
//agg view on the aggregate post?
// if(Galleries.GetGallery(gp.SectionID).EnableAggBugs)
// desc = string.Format("{0}<img src=\"{1}\" width=\"1\" height=\"1\">",desc,FormatUrl(Globals.GetSiteUrls().AggView(wp.PostID)));
base.WriteElementString("description",desc);
}
}
protected override void WriteItem(Post p)
{
base.WriteItem (p);
// BaseGalleryRssWriter.AddCategoriesToWriter(p,p.Section as Weblog,this.BaseUrl,this);
}
protected override void WriteChannel()
{
string url = null;
string desc = null;
if(HasGroup)
{
url = GalleryUrls.Instance().GalleryListing;
desc = CurrentGroup.Name;
}
else
{
url = GalleryUrls.Instance().Home;
desc = CSContext.Current.SiteSettings.SiteDescription;
}
BuildChannel(url,desc);
}
protected override string BuildLink(Post p)
{
return GalleryUrls.Instance().PictureUrl(p as GalleryPost) ;
}
protected override string GetUserName(Post p)
{
GalleryPost gp = p as GalleryPost;
if (gp == null)
return base.GetUserName(p);
else
return Globals.HtmlDecode(gp.DisplayName);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -