Beispiel #1
0
    public HtmlString comicHeading(int comicNo, string headingTag = "h1", string dateFormat = "MMMM, d yyyy")//create heading for comic page
    //intialize variables
    {
        string   edit           = "";
        string   publishHeading = "";
        int      pageCount      = 0;
        DateTime publishDate    = Convert.ToDateTime(comicDate(comicNo));

        //load settings, comic list, and comic page xml
        var load      = new Comic();
        var settings  = load.LoadComic("/App_Data/WebcomicX.xml");
        var comicList = load.LoadComic("/content/xml/comics/comic-list.xml");
        var pagesDoc  = load.LoadComic("/content/xml/comics/comic-" + comicNo + ".xml");

        pageCount = pagesDoc.Descendants("Page").Count();
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            //if user is authenticated display edit page link
            edit = " <a class='edit'" + (comicNo != 0 ? "href = '/webcomicx/admin/edit-comic/" + comicNo.ToString() + "' > Edit": "href = '/webcomicx/admin/new-comic/ '> Post Comic") + "</a>";
        }

        //set publishHeading variable with date and author
        if (load.comicAuthor(comicNo) != "")
        {
            publishHeading = "<h5><span>By " + load.comicAuthor(comicNo) + " </span> <time datetime='" + publishDate.ToString("yyyy-MM-d") + "' id='pubDate' itemprop='datePublished' pubdate>" + publishDate.ToString(dateFormat) + "</time></h5>";
        }
        else if (load.PrimaryAuthor().ToString() != "")
        {
            publishHeading = "<h5><span>" + load.PrimaryAuthor(link: true) + "</span> <time datetime='" + publishDate.ToString("yyyy-MM-d") + "' id='pubDate' itemprop='datePublished' pubdate>" + publishDate.ToString(dateFormat) + "</time></h5>";
        }
        else
        {
            publishHeading = "<h5><time datetime='" + publishDate.ToString("yyyy-MM-d") + "' id='pubDate' itemprop='datePublished' pubdate>" + publishDate.ToString(dateFormat) + "</time></h5>";
        }
        //add comic title, and publishHeading to create comic heading
        string comicHeading = "<" + headingTag + " itemprop='headline'>" + load.comicTitle(comicNo) + edit + "</" + headingTag + ">" + publishHeading;

        return(new HtmlString(comicHeading));
    }