Example #1
0
 public string GetDescription(string value)
 {
     HtmlWriterOptions options = new HtmlWriterOptions();
     options.BaseHref = Uri.IsWellFormedUriString(AccountFeed.LinkUrl, UriKind.Absolute) ? new Uri(AccountFeed.LinkUrl) : null;
     options.RewriteImgSrc = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");
     return Renderer.CleanHtml(value, options);
 }
Example #2
0
 public string GetDescription(string s, string uri)
 {
     HtmlWriterOptions options = new HtmlWriterOptions();
     options.RewriteImgSize = new Size(0, 0);
     options.BaseHref = Uri.IsWellFormedUriString(uri, UriKind.Absolute) ? new Uri(uri) : null;
     options.RewriteImgSrc = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");
     return Renderer.CleanHtml(s, options);
 }
Example #3
0
 public static string CleanHtml(string html)
 {
     Html.HtmlWriterOptions options = new Html.HtmlWriterOptions();
     options.ReduceConsecutiveSpace = true;
     options.DecodeSpace            = true;
     options.ReplaceQuotes          = true;
     options.BaseHref      = null;
     options.RewriteImgSrc = null;
     return(CleanHtml(html, options));
 }
 public string GetSummary(string summary, string link)
 {
     Uri uri = null;
     Uri.TryCreate(link, UriKind.Absolute, out uri);
     Uri imgrewriteuri = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");
     HtmlWriterOptions options = new HtmlWriterOptions();
     options.BaseHref = uri;
     options.RewriteImgSrc = imgrewriteuri;
     return Renderer.CleanHtml(summary, options);
 }
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TransitAccountFeedItem tfi = GetAccountFeedItem();

            if (tfi == null)
            {
                Response.Redirect("AccountFeedItemsView.aspx");
                return;
            }

            licenseView.AccountId = tfi.AccountId;

            labelAccountName.Text = Renderer.Render(tfi.AccountName);
            imageAccount.Src = string.Format("AccountPictureThumbnail.aspx?id={0}", tfi.AccountPictureId);

            this.Title = string.Format("{0}'s {1} in {2}",
                Renderer.Render(tfi.AccountName),
                Renderer.Render(tfi.Title),
                Renderer.Render(tfi.AccountFeedName));

            FeedTitle.Text = Renderer.Render(tfi.AccountFeedName);
            FeedItemCreated.Text = base.Adjust(tfi.Created).ToString();
            FeedItemTitle.NavigateUrl = tfi.Link;

            linkAccountView.HRef = string.Format("AccountView.aspx?id={0}", tfi.AccountId);
            FeedTitle.NavigateUrl = string.Format("AccountFeedView.aspx?id={0}", tfi.AccountFeedId);
            FeedXPosted.NavigateUrl = Render(tfi.Link);

            FeedItemTitle.Text = Renderer.Render(tfi.Title);

            Uri imgrewriteuri = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");

            HtmlWriterOptions options = new HtmlWriterOptions();
            options.BaseHref = Uri.IsWellFormedUriString(tfi.AccountFeedLinkUrl, UriKind.Absolute) ? new Uri(tfi.AccountFeedLinkUrl) : null;
            options.RewriteImgSrc = imgrewriteuri;
            FeedItemDescription.Text = Renderer.CleanHtml(tfi.Description, options);

            FeedItemComments.DiscussionId = SessionManager.GetCount<TransitDiscussion, string, int>(
                typeof(AccountFeedItem).Name, RequestId, SessionManager.DiscussionService.GetOrCreateDiscussionId);

            GetDataFeature(sender, e);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.AccountFeedName, Request, string.Format("AccountFeedView.aspx?id={0}", tfi.AccountFeedId)));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.Title, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Example #6
0
 public static string CleanHtml(string html, Html.HtmlWriterOptions options)
 {
     try
     {
         Html.HtmlReader r  = new Html.HtmlReader(html);
         StringWriter    sw = new StringWriter();
         Html.HtmlWriter w  = new Html.HtmlWriter(sw, options);
         while (!r.EOF)
         {
             w.WriteNode(r, true);
         }
         w.Close();
         return(sw.ToString());
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SyndicationService.TransitAccountFeedItem tfi = GetAccountFeedItem();

            if (tfi == null)
            {
                Response.Redirect("AccountFeedItemsView.aspx");
                return;
            }

            this.Title = string.Format("{0}'s {1} in {2}",
                Renderer.Render(tfi.AccountName),
                Renderer.Render(tfi.Title),
                Renderer.Render(tfi.AccountFeedName));

            feeditemCreated.Text = SessionManager.Adjust(tfi.Created).ToString();
            feeditemXPosted.NavigateUrl = Renderer.Render(tfi.Link);

            HtmlWriterOptions options = new HtmlWriterOptions();
            options.RewriteImgSize = new Size(0, 0);
            options.BaseHref = Uri.IsWellFormedUriString(tfi.AccountFeedLinkUrl, UriKind.Absolute) ? new Uri(tfi.AccountFeedLinkUrl) : null;
            options.RewriteImgSrc = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");
            feeditemDescription.Text = Renderer.CleanHtml(tfi.Description, options);

            int discussion_id = SessionManager.GetCount<DiscussionService.TransitDiscussion, DiscussionService.ServiceQueryOptions, string, int>(
                "AccountFeedItem", RequestId, SessionManager.DiscussionService.GetOrCreateDiscussionId);

            linkDiscussion.NavigateUrl = string.Format("DiscussionView.aspx?id={0}", discussion_id);

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Blogs", Request, "AccountFeedItemsView.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.AccountFeedName, Request, string.Format("AccountFeedView.aspx?id={0}", tfi.AccountFeedId)));
            sitemapdata.Add(new SiteMapDataAttributeNode(tfi.Title, Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Example #8
0
 public static string CleanHtml(string html)
 {
     Html.HtmlWriterOptions options = new Html.HtmlWriterOptions();
     options.ReduceConsecutiveSpace = true;
     options.DecodeSpace = true;
     options.ReplaceQuotes = true;
     options.BaseHref = null;
     options.RewriteImgSrc = null;
     return CleanHtml(html, options);
 }
Example #9
0
    public void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            linkChooseLicense.NavigateUrl = string.Format("http://creativecommons.org/license/?partner={0}&exit_url={1}",
                Renderer.Render(SessionManager.GetCachedConfiguration("SnCore.Title", "SnCore")),
                Renderer.UrlEncode(Request.Url.ToString() + "?license_url=[license_url]&license_name=[license_name]&license_button=[license_button]"));

            string license_url = Request.QueryString["license_url"];
            string license_name = Request.QueryString["license_name"];
            string license_button = Request.QueryString["license_button"];

            TransitAccountLicense tal = SessionManager.LicenseService.GetAccountLicenseByAccountId(
                SessionManager.Ticket, SessionManager.AccountId);

            linkChooseLicense.Text = (tal == null) ? "&#187; Choose a License" : "&#187; Choose a New License";

            if (!string.IsNullOrEmpty(license_url))
            {
                if (tal == null)
                {
                    tal = new TransitAccountLicense();
                    tal.AccountId = SessionManager.Account.Id;
                }

                tal.LicenseUrl = Renderer.UrlDecode(license_url);
                tal.ImageUrl = Renderer.UrlDecode(license_button);
                tal.Name = Renderer.UrlDecode(license_name);

                tal.Id = SessionManager.CreateOrUpdate<TransitAccountLicense>(
                    tal, SessionManager.LicenseService.CreateOrUpdateAccountLicense);

                Redirect("AccountLicenseEdit.aspx");
            }

            licenseImage.Visible = (tal != null);
            linkDeleteLicense.Visible = (tal != null);
            licenseDiv.Visible = (tal != null);

            if (tal != null && !string.IsNullOrEmpty(tal.LicenseUrl))
            {
                string key = string.Format("license:{0}", tal.Name);
                string license = (string)Cache[key];
                if (string.IsNullOrEmpty(license))
                {
                    WebClient client = new WebClient();
                    client.Headers["Accept"] = "*/*";
                    client.Headers["User-Agent"] = SessionManager.GetCachedConfiguration("SnCore.Web.UserAgent", "SnCore/1.0");
                    license = client.DownloadString(tal.LicenseUrl);
                    license = license.Substring(license.IndexOf("<div id=\"deed\""));
                    license = license.Substring(0, license.LastIndexOf("</div>") + 4);

                    HtmlWriterOptions options = new HtmlWriterOptions();
                    options.BaseHref = new Uri("http://creativecommons.org/");
                    license = Renderer.CleanHtml(license, options);
                    Cache[key] = license;
                }

                licenseContent.Text = license;
                licenseImage.Src = tal.ImageUrl;
                licenseLink.HRef = tal.LicenseUrl;
                licenseImage.Alt = Renderer.Render(tal.Name);
            }

            SiteMapDataAttribute sitemapdata = new SiteMapDataAttribute();
            sitemapdata.Add(new SiteMapDataAttributeNode("Me Me", Request, "AccountManage.aspx"));
            sitemapdata.Add(new SiteMapDataAttributeNode("Creative License", Request.Url));
            StackSiteMap(sitemapdata);
        }
    }
Example #10
0
 public HtmlWriter(Stream stream, Encoding enc, HtmlWriterOptions options)
     : base(stream, enc)
 {
     mOptions = options;
 }
Example #11
0
 public HtmlWriter(StringBuilder builder, HtmlWriterOptions options)
     : base(new StringWriter(builder))
 {
     mOptions = options;
 }
Example #12
0
 public HtmlWriter(TextWriter writer, HtmlWriterOptions options)
     : base(writer)
 {
     mOptions = options;
 }
 public string GetDescription(object link, object description)
 {
     if (LinkDescription)
     {
         return string.Format("<a href='{0}' target='_blank'>{1}</a>",
             link, RenderEx(description));
     }
     else
     {
         Uri feedlinkUri = null;
         Uri.TryCreate(Feed.LinkUrl, UriKind.Absolute, out feedlinkUri);
         Uri imgrewriteuri = new Uri(SessionManager.WebsiteUri, "AccountFeedItemPicture.aspx?src={url}");
         HtmlWriterOptions options = new HtmlWriterOptions();
         options.BaseHref = feedlinkUri;
         options.RewriteImgSrc = imgrewriteuri;
         return Renderer.CleanHtml(description.ToString(), options);
     }
 }
Example #14
0
 public HtmlWriter(Stream stream, Encoding enc, HtmlWriterOptions options)
     : base(stream, enc)
 {
     mOptions = options;
 }
Example #15
0
 public HtmlWriter(StringBuilder builder, HtmlWriterOptions options)
     : base(new StringWriter(builder))
 {
     mOptions = options;
 }
Example #16
0
 public HtmlWriter(TextWriter writer, HtmlWriterOptions options)
     : base(writer)
 {
     mOptions = options;
 }