Пример #1
0
        //+
        //- $GetDataSource -//
        private List <BlogEntry> GetDataSource()
        {
            String blogGuid = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.BlogGuid);

            if (String.IsNullOrEmpty(blogGuid))
            {
                throw new ArgumentNullException("BlogGuid is required.");
            }
            //+
            List <BlogEntry> blogEntryList = new List <BlogEntry>();

            if (this.AccessType != AccessType.Index)
            {
                blogEntryList = BlogAgent.GetNetBlogEntryList(blogGuid, this.Label, this.Archive, this.Link, BlogSection.GetConfigSection().EntriesToShow, false);
                //+
                if (this.AccessType == AccessType.Link)
                {
                    if (blogEntryList != null)
                    {
                        HttpData.SetScopedItem <String>(Info.Scope, "BlogEntryTitle", blogEntryList[0].Title);
                        //+
                        this.BlogEntryGuid = blogEntryList[0].Guid;
                    }
                }
            }
            //+
            return(blogEntryList);
        }
Пример #2
0
        //+
        //- #OnLoad -//
        protected override void OnLoad(EventArgs e)
        {
            String link = Themelia.Web.HttpData.GetScopedItem <String>(Info.Scope, Info.CustomLink);

            //+
            if (!String.IsNullOrEmpty(link))
            {
                Minima.Service.BlogEntry blogEntry = BlogAgent.GetSingleBlogEntryByLink(this.BlogGuid, link, this.IgnoreBlogEntryFooter);
                if (blogEntry != null)
                {
                    String   labelSeries = SeriesHelper.GetBlogEntryLabelSeries(blogEntry);
                    Template template    = DataTemplateTemplateFactory.CreatePostTemplate(false, this.HidePostDateTime, this.ShowAuthorSeries, this.ShowLabelSeries, labelSeries, true, false, Minima.Service.AllowCommentStatus.Disabled, false, String.Empty);
                    String   output      = template.Interpolate(new Map(
                                                                    new MapEntry("$Title$", blogEntry.Title),
                                                                    new MapEntry("$DateTimeString$", String.Format("{0}, {1} {2}, {3}", blogEntry.PostDateTime.DayOfWeek, blogEntry.PostDateTime.ToString("MMMM"), blogEntry.PostDateTime.Day, blogEntry.PostDateTime.Year)),
                                                                    new MapEntry("$Content$", blogEntry.Content),
                                                                    new MapEntry("$AuthorSeries$", SeriesHelper.GetBlogEntryAuthorSeries(blogEntry)),
                                                                    new MapEntry("$DateTimeDisplay$", String.Format("{0}/{1}/{2} {3}", blogEntry.PostDateTime.Month, blogEntry.PostDateTime.Day, blogEntry.PostDateTime.Year, blogEntry.PostDateTime.ToShortTimeString())),
                                                                    new MapEntry("$LabelSeries$", labelSeries)
                                                                    )
                                                                );
                    output = this.CodeParserSeries.ParseCode(output);
                    //+
                    this.Controls.Add(new System.Web.UI.WebControls.Literal
                    {
                        Text = output
                    });
                    //+
                    HttpData.SetScopedItem("MinimaBlogEntry", "Title", blogEntry.Title);
                }
            }
            //+
            base.OnPreRender(e);
        }
Пример #3
0
        //+
        //- @OnPreProcessorExecute -//
        public override void OnPreProcessorExecute(HttpContext context, params Object[] parameterArray)
        {
            WebDomainData webDomainData = WebDomain.CurrentData;
            ComponentData componentData = webDomainData.ComponentDataList[Info.Key];

            if (componentData != null)
            {
                ParameterData blogGuidParameter = componentData.ParameterDataList[Info.BlogGuid];
                if (blogGuidParameter != null)
                {
                    HttpData.SetScopedItem <String>(Info.Scope, Info.BlogGuid, blogGuidParameter.Value);
                }
            }
            //+ url
            if (!Themelia.Web.Routing.PassThroughHttpHandler.ForceUse)
            {
                DetectDestination();
            }
            //+ blog page
            if (componentData != null)
            {
                ParameterData blogPageParameter = componentData.ParameterDataList[Info.BlogPage];
                if (blogPageParameter != null)
                {
                    HttpData.SetScopedItem <String>(Info.Scope, Info.BlogPage, blogPageParameter.Value);
                    return;
                }
            }
            //+ blog page fallback
            HttpData.SetScopedItem <String>(Info.Scope, Info.BlogPage, "~/default.aspx");
        }
Пример #4
0
 //+
 //- @Execute -//
 public override InitProcessorBase Execute(HttpContext context, params Object[] parameterArray)
 {
     if (!Themelia.Web.Processing.PassThroughHttpHandler.ForceUse || !Themelia.Collection.IsNullOrEmpty(parameterArray))
     {
         HttpData.SetScopedItem <String>(Info.Scope, Info.BlogGuid, parameterArray[0] as String);
         DetectDestination();
     }
     //+
     return(null);
 }
Пример #5
0
        //- $DetectDestination -//
        private void DetectDestination()
        {
            String finderLabel = "/label/";
            String uri         = Http.Url.ToString().ToLower();

            //+ label
            if (Http.Url.ToString().ToLower().Contains(finderLabel))
            {
                String label = uri.Substring(uri.IndexOf(finderLabel) + finderLabel.Length, uri.Length - (uri.IndexOf(finderLabel) + finderLabel.Length));
                if (!String.IsNullOrEmpty(label))
                {
                    Int32 extraSlash = label.IndexOf("/");
                    if (extraSlash > -1)
                    {
                        label = label.Substring(0, extraSlash);
                    }
                    Int32 questionMark = label.IndexOf("?");
                    if (questionMark > -1)
                    {
                        label = label.Substring(0, questionMark);
                    }
                    String           labelTitle       = String.Empty;
                    ReaderWriterLock readerWriterLock = new ReaderWriterLock();
                    try
                    {
                        readerWriterLock.AcquireReaderLock(Timeout.Infinite);
                        //+
                        labelTitle = LabelMap.Pull(label);
                        if (String.IsNullOrEmpty(labelTitle))
                        {
                            Minima.Service.Label labelEntity = LabelAgent.GetLabelByNetTitle(label);
                            if (labelEntity != null)
                            {
                                labelTitle = labelEntity.Title;
                                LockCookie lockCookie = readerWriterLock.UpgradeToWriterLock(Timeout.Infinite);
                                try
                                {
                                    if (!LabelMap.ContainsKey(label))
                                    {
                                        LabelMap.Add(label, labelTitle);
                                    }
                                }
                                catch
                                {
                                    //+ doesn't matter
                                }
                                finally
                                {
                                    readerWriterLock.DowngradeFromWriterLock(ref lockCookie);
                                }
                            }
                        }
                    }
                    finally
                    {
                        readerWriterLock.ReleaseReaderLock();
                    }
                    HttpData.SetScopedItem <String>(Info.Scope, "Label", label);
                    HttpData.SetScopedItem <String>(Info.Scope, "LabelTitle", labelTitle);
                    return;
                }
            }
            //+ link
            String linkCapturePattern = "[\\-a-z0-9]+$";
            String linkMatchPattern   = "\\/200\\d\\/\\d{2}\\/[\\-a-z0-9]+$";
            String linkMatchUri       = String.Empty;

            if (uri[uri.Length - 1] == '/')
            {
                linkMatchUri = uri.Substring(0, uri.Length - 1);
            }
            else
            {
                linkMatchUri = uri;
            }
            if (new Regex(linkMatchPattern).IsMatch(linkMatchUri))
            {
                Regex  a    = new Regex(linkCapturePattern);
                Match  m    = a.Match(linkMatchUri);
                String link = m.Captures[0].Value;
                if (!String.IsNullOrEmpty(link))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Link", link);
                    return;
                }
            }
            linkCapturePattern = "[\\-a-z0-9]+\\.aspx";
            linkMatchPattern   = "\\/200\\d\\/\\d{2}\\/[\\-a-z0-9]+\\.aspx";
            if (new Regex(linkMatchPattern).IsMatch(uri))
            {
                Regex  a    = new Regex(linkCapturePattern);
                Match  m    = a.Match(uri);
                String link = m.Captures[0].Value;
                link = link.Substring(0, link.Length - 5);
                if (!String.IsNullOrEmpty(link))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Link", link);
                    return;
                }
            }
            //+ archive
            String archiveCapturePattern = "200(\\d)\\/(\\d{2})";
            String archiveMatchPattern   = "\\/" + archiveCapturePattern;

            if (new Regex(archiveMatchPattern).IsMatch(uri))
            {
                Regex  a       = new Regex(archiveCapturePattern);
                Match  m       = a.Match(uri);
                String archive = m.Captures[0].Value;
                if (!String.IsNullOrEmpty(archive))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Archive", archive);
                    //+
                    String[] parts = archive.Split('/');
                    HttpData.SetScopedItem <Int32>(Info.Scope, "ArchiveYear", Parser.ParseInt32(parts[0], 0));
                    HttpData.SetScopedItem <Int32>(Info.Scope, "ArchiveMonth", Parser.ParseInt32(parts[1], 0));
                    return;
                }
            }
            //+ index
            String indexCapturePattern = "/index/(?<year>20[0-9]{2})";
            String indexMatchPattern   = indexCapturePattern;

            if (new Regex(indexMatchPattern).IsMatch(uri))
            {
                Regex  a     = new Regex(indexCapturePattern);
                Match  m     = a.Match(uri);
                String index = m.Groups["year"].Value;
                if (!String.IsNullOrEmpty(index))
                {
                    HttpData.SetScopedItem <Int32>(Info.Scope, "Index", Parser.ParseInt32(index, 0));
                    return;
                }
            }
        }
Пример #6
0
        //- $DetectDestination -//
        private void DetectDestination()
        {
            String finderLabel = "/label/";
            String uri         = Http.AbsoluteUrl;

            //+ label
            if (uri.Contains(finderLabel))
            {
                String label = uri.Substring(uri.IndexOf(finderLabel) + finderLabel.Length, uri.Length - (uri.IndexOf(finderLabel) + finderLabel.Length));
                if (!String.IsNullOrEmpty(label))
                {
                    Int32 extraSlash = label.IndexOf("/");
                    if (extraSlash > -1)
                    {
                        label = label.Substring(0, extraSlash);
                    }
                    Int32 questionMark = label.IndexOf("?");
                    if (questionMark > -1)
                    {
                        label = label.Substring(0, questionMark);
                    }
                    String labelTitle = String.Empty;
                    ReaderWriterLockSlim readerWriterLockSlim = new ReaderWriterLockSlim();
                    try
                    {
                        readerWriterLockSlim.EnterUpgradeableReadLock();
                        //+
                        labelTitle = LabelMap.Pull(label);
                        if (String.IsNullOrEmpty(labelTitle))
                        {
                            Minima.Service.Label labelEntity = LabelAgent.GetLabelByNetTitle(label);
                            if (labelEntity != null)
                            {
                                labelTitle = labelEntity.Title;
                                readerWriterLockSlim.EnterWriteLock();
                                try
                                {
                                    if (!LabelMap.ContainsKey(label))
                                    {
                                        LabelMap.Add(label, labelTitle);
                                    }
                                }
                                catch
                                {
                                    //+ doesn't matter
                                }
                                finally
                                {
                                    readerWriterLockSlim.ExitWriteLock();
                                }
                            }
                        }
                    }
                    finally
                    {
                        readerWriterLockSlim.ExitUpgradeableReadLock();
                    }
                    HttpData.SetScopedItem <String>(Info.Scope, "Label", label);
                    HttpData.SetScopedItem <String>(Info.Scope, "LabelTitle", labelTitle);
                    return;
                }
            }
            //+ link
            String linkCapturePattern = "[\\-a-z0-9]+$";
            String linkMatchPattern   = "\\/2\\d\\d\\d\\/\\d{2}\\/[\\-a-z0-9]+$";
            String linkMatchUri       = String.Empty;

            if (uri[uri.Length - 1] == '/')
            {
                linkMatchUri = uri.Substring(0, uri.Length - 1);
            }
            else
            {
                linkMatchUri = uri;
            }
            if (new Regex(linkMatchPattern).IsMatch(linkMatchUri))
            {
                Regex  a    = new Regex(linkCapturePattern);
                Match  m    = a.Match(linkMatchUri);
                String link = m.Captures[0].Value;
                if (!String.IsNullOrEmpty(link))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Link", WebDomain.RelativeUrl);
                    return;
                }
            }
            //++ due to how IIS6 works, this is only compatible with IIS7 integrated mode
            linkCapturePattern = "[\\-a-z0-9]+\\.aspx";
            linkMatchPattern   = "\\/2\\d\\d\\d\\/\\d{2}\\/[\\-a-z0-9]+\\.aspx";
            if (new Regex(linkMatchPattern).IsMatch(uri))
            {
                Regex  a    = new Regex(linkCapturePattern);
                Match  m    = a.Match(uri);
                String link = m.Captures[0].Value;
                link = link.Substring(0, link.Length - 5);
                if (!String.IsNullOrEmpty(link))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Link", WebDomain.RelativeUrl.Substring(0, WebDomain.RelativeUrl.Length - 5));
                    return;
                }
            }
            //+ archive
            String archiveCapturePattern = "2(\\d\\d\\d)\\/(\\d{2})";
            String archiveMatchPattern   = "\\/" + archiveCapturePattern;

            if (new Regex(archiveMatchPattern).IsMatch(uri))
            {
                Regex  a       = new Regex(archiveCapturePattern);
                Match  m       = a.Match(uri);
                String archive = m.Captures[0].Value;
                if (!String.IsNullOrEmpty(archive))
                {
                    HttpData.SetScopedItem <String>(Info.Scope, "Archive", archive);
                    //+
                    String[] parts = archive.Split('/');
                    HttpData.SetScopedItem <Int32>(Info.Scope, "ArchiveYear", Parser.ParseInt32(parts[0], 0));
                    HttpData.SetScopedItem <Int32>(Info.Scope, "ArchiveMonth", Parser.ParseInt32(parts[1], 0));
                    return;
                }
            }
            //+ index
            String indexCapturePattern = "/index/(?<year>20[0-9]{2})";
            String indexMatchPattern   = indexCapturePattern;

            if (new Regex(indexMatchPattern).IsMatch(uri))
            {
                Regex  a     = new Regex(indexCapturePattern);
                Match  m     = a.Match(uri);
                String index = m.Groups["year"].Value;
                if (!String.IsNullOrEmpty(index))
                {
                    HttpData.SetScopedItem <Int32>(Info.Scope, "Index", Parser.ParseInt32(index, 0));
                    return;
                }
            }
            //+
            HttpData.SetScopedItem <String>(Info.Scope, "CustomLink", WebDomain.RelativeUrl);
        }