Exemplo n.º 1
0
        /// <summary>
        /// Retrieves and caches the specified remote CSS.
        /// </summary>
        /// <param name="file">
        /// The remote URL
        /// </param>
        /// <param name="cacheKey">
        /// The key used to insert this script into the cache.
        /// </param>
        /// <returns>
        /// The retrieve remote css.
        /// </returns>
        private static string RetrieveRemoteCss(string file, string cacheKey)
        {
            Uri url;

            if (Uri.TryCreate(file, UriKind.Absolute, out url))
            {
                try
                {
                    var    remoteFile = new RemoteFile(url, false);
                    string css        = remoteFile.GetFileAsString();
                    css = ProcessCss(css);

                    // Insert into cache
                    Applications.CurrentInstance.Cache.Insert(
                        cacheKey,
                        css,
                        null,
                        Cache.NoAbsoluteExpiration,
                        new TimeSpan(3, 0, 0, 0));

                    return(css);
                }
                catch (SocketException)
                {
                    // The remote site is currently down. Try again next time.
                }
            }

            return(string.Empty);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Sends the trackback or pingback message.
        ///     <remarks>
        /// It will try to send a trackback message first, and if the refered web page
        ///         doesn't support trackbacks, a pingback is sent.
        ///     </remarks>
        /// </summary>
        /// <param name="item">
        /// The publishable item.
        /// </param>
        /// <param name="itemUrl">
        /// The item Url.
        /// </param>
        public static void Send(IPublishable item, Uri itemUrl)
        {
            foreach (var url in GetUrlsFromContent(item.Content))
            {
                var trackbackSent = false;

                if (BlogSettings.Instance.EnableTrackBackSend)
                {
                    // ignoreRemoteDownloadSettings should be set to true
                    // for backwards compatibilty with Utils.DownloadWebPage.
                    var remoteFile = new RemoteFile(url, true);
                    var pageContent = remoteFile.GetFileAsString(); // ReadFromWeb(url);
                    var trackbackUrl = GetTrackBackUrlFromPage(pageContent);

                    if (trackbackUrl != null)
                    {
                        var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
                        trackbackSent = Trackback.Send(message);
                    }
                }

                if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
                {
                    Pingback.Send(itemUrl, url);
                }
            }
        }
Exemplo n.º 3
0
        public static void Send(IPublishable item, Uri itemUrl)
        {
            foreach (var url in GetUrlsFromContent(item.Content))
            {
                var trackbackSent = false;

                if (BlogSettings.Instance.EnableTrackBackSend)
                {
                    var remoteFile = new RemoteFile(url, true);
                    var pageContent = remoteFile.GetFileAsString();
                    var trackbackUrl = GetTrackBackUrlFromPage(pageContent);

                    if (trackbackUrl != null)
                    {
                        var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
                        trackbackSent = Trackback.Send(message);
                    }
                }

                if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
                {
                    Pingback.Send(itemUrl, url);
                }
            }
        }
Exemplo n.º 4
0
        public static void Send(IPublishable item, Uri itemUrl)
        {
            foreach (var url in GetUrlsFromContent(item.Content))
            {
                var trackbackSent = false;

                if (BlogSettings.Instance.EnableTrackBackSend)
                {
                    var remoteFile   = new RemoteFile(url, true);
                    var pageContent  = remoteFile.GetFileAsString();
                    var trackbackUrl = GetTrackBackUrlFromPage(pageContent);

                    if (trackbackUrl != null)
                    {
                        var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
                        trackbackSent = Trackback.Send(message);
                    }
                }

                if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
                {
                    Pingback.Send(itemUrl, url);
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Sends the trackback or pingback message.
        ///     <remarks>
        /// It will try to send a trackback message first, and if the refered web page
        ///         doesn't support trackbacks, a pingback is sent.
        ///     </remarks>
        /// </summary>
        /// <param name="item">
        /// The publishable item.
        /// </param>
        /// <param name="itemUrl">
        /// The item Url.
        /// </param>
        public static void Send(IPublishable item, Uri itemUrl)
        {
            foreach (var url in GetUrlsFromContent(item.Content))
            {
                var trackbackSent = false;

                if (BlogSettings.Instance.EnableTrackBackSend)
                {
                    // ignoreRemoteDownloadSettings should be set to true
                    // for backwards compatibilty with Utils.DownloadWebPage.
                    var remoteFile   = new RemoteFile(url, true);
                    var pageContent  = remoteFile.GetFileAsString(); // ReadFromWeb(url);
                    var trackbackUrl = GetTrackBackUrlFromPage(pageContent);

                    if (trackbackUrl != null)
                    {
                        var message = new TrackbackMessage(item, trackbackUrl, itemUrl);
                        trackbackSent = Trackback.Send(message);
                    }
                }

                if (!trackbackSent && BlogSettings.Instance.EnablePingBackSend)
                {
                    Pingback.Send(itemUrl, url);
                }
            }
        }
Exemplo n.º 6
0
        protected virtual Uri GetTrackbackUrl(Uri url)
        {
            // ignoreRemoteDownloadSettings should be set to true
            // for backwards compatibilty with Utils.DownloadWebPage.
            var remoteFile   = new RemoteFile(url, true);
            var pageContent  = remoteFile.GetFileAsString(); // ReadFromWeb(url);
            var trackbackUrl = GetTrackBackUrlFromPage(pageContent);

            return(trackbackUrl);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Parse the HTML of the source page.
        /// </summary>
        /// <param name="sourceUrl">
        /// The source Url.
        /// </param>
        /// <param name="targetUrl">
        /// The target Url.
        /// </param>
        private void ExamineSourcePage(string sourceUrl, string targetUrl)
        {
            try
            {
                var remoteFile = new RemoteFile(new Uri(sourceUrl), true);
                var html       = remoteFile.GetFileAsString();
                this.sourceHasLink = html.ToUpperInvariant().Contains(targetUrl.ToUpperInvariant());
            }
            catch (WebException)
            {
                this.sourceHasLink = false;

                // throw new ArgumentException("Trackback sender does not exists: " + sourceUrl, ex);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Parse the HTML of the source page.
 /// </summary>
 /// <param name="sourceUrl">
 /// The source Url.
 /// </param>
 /// <param name="targetUrl">
 /// The target Url.
 /// </param>
 private void ExamineSourcePage(string sourceUrl, string targetUrl)
 {
     try
     {
         var remoteFile = new RemoteFile(new Uri(sourceUrl), true);
         var html       = remoteFile.GetFileAsString();
         this.title         = RegexTitle.Match(html).Value.Trim();
         this.containsHtml  = RegexHtml.IsMatch(this.title);
         this.sourceHasLink = html.ToUpperInvariant().Contains(targetUrl.ToUpperInvariant());
     }
     catch (WebException)
     {
         this.sourceHasLink = false;
     }
 }
        /// <summary>
        /// Retrieves and cached the specified remote script.
        /// </summary>
        /// <param name="file">
        /// The remote URL
        /// </param>
        /// <param name="cacheKey">The key used to insert this script into the cache.</param>
        /// <param name="minify">Whether or not the remote script should be minified</param>
        /// <returns>
        /// The retrieve remote script.
        /// </returns>
        private static string RetrieveRemoteScript(string file, string cacheKey, bool minify)
        {
            Uri url;

            if (Uri.TryCreate(file, UriKind.Absolute, out url))
            {
                try
                {
                    var    remoteFile = new RemoteFile(url, false);
                    string script     = remoteFile.GetFileAsString();
                    script = ProcessScript(script, file, minify);
                    HttpContext.Current.Cache.Insert(cacheKey, script, null, Cache.NoAbsoluteExpiration, new TimeSpan(3, 0, 0, 0));
                    return(script);
                }
                catch (SocketException)
                {
                    // The remote site is currently down. Try again next time.
                }
            }

            return(String.Empty);
        }
        /// <summary>
        /// Parse the HTML of the source page.
        /// </summary>
        /// <param name="sourceUrl">
        /// The source Url.
        /// </param>
        /// <param name="targetUrl">
        /// The target Url.
        /// </param>
        private void ExamineSourcePage(string sourceUrl, string targetUrl)
        {
            try
            {
                var remoteFile = new RemoteFile(new Uri(sourceUrl), true);
                var html = remoteFile.GetFileAsString();
                this.sourceHasLink = html.ToUpperInvariant().Contains(targetUrl.ToUpperInvariant());
                
            }
            catch (WebException)
            {
                this.sourceHasLink = false;

                // throw new ArgumentException("Trackback sender does not exists: " + sourceUrl, ex);
            }
        }
Exemplo n.º 11
0
 protected virtual Uri GetTrackbackUrl(Uri url)
 {
     // ignoreRemoteDownloadSettings should be set to true
     // for backwards compatibilty with Utils.DownloadWebPage.
     var remoteFile = new RemoteFile(url, true);
     var pageContent = remoteFile.GetFileAsString(); // ReadFromWeb(url);
     var trackbackUrl = GetTrackBackUrlFromPage(pageContent);
     return trackbackUrl;
 }
        /// <summary>
        /// Parse the HTML of the source page.
        /// </summary>
        /// <param name="sourceUrl">
        /// The source Url.
        /// </param>
        /// <param name="targetUrl">
        /// The target Url.
        /// </param>
        private void ExamineSourcePage(string sourceUrl, string targetUrl)
        {
            try
            {

                var remoteFile = new RemoteFile(new Uri(sourceUrl), true);
                var html = remoteFile.GetFileAsString();
                this.title = RegexTitle.Match(html).Value.Trim();
                this.containsHtml = RegexHtml.IsMatch(this.title);
                this.sourceHasLink = html.ToUpperInvariant().Contains(targetUrl.ToUpperInvariant());
            }
            catch (WebException)
            {
                this.sourceHasLink = false;
            }
        }
Exemplo n.º 13
0
        /// <summary>
        /// Retrieves and caches the specified remote CSS.
        /// </summary>
        /// <param name="file">
        /// The remote URL
        /// </param>
        /// <param name="cacheKey">
        /// The key used to insert this script into the cache.
        /// </param>
        /// <returns>
        /// The retrieve remote css.
        /// </returns>
        private static string RetrieveRemoteCss(string file, string cacheKey)
        {
            Uri url;

            if (Uri.TryCreate(file, UriKind.Absolute, out url))
            {
                try
                {
                    var remoteFile = new RemoteFile(url, false);
                    string css = remoteFile.GetFileAsString();
                    css = ProcessCss(css);

                    // Insert into cache
                    HttpContext.Current.Cache.Insert(
                        cacheKey,
                        css,
                        null,
                        Cache.NoAbsoluteExpiration,
                        new TimeSpan(3, 0, 0, 0));

                    return css;
                }
                catch (SocketException)
                {
                    // The remote site is currently down. Try again next time.
                }
            }

            return string.Empty;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Retrieves and cached the specified remote script.
        /// </summary>
        /// <param name="file">
        /// The remote URL
        /// </param>
        /// <param name="cacheKey">The key used to insert this script into the cache.</param>
        /// <param name="minify">Whether or not the remote script should be minified</param>
        /// <returns>
        /// The retrieve remote script.
        /// </returns>
        private static string RetrieveRemoteScript(string file, string cacheKey, bool minify)
        {
            Uri url;

            if (Uri.TryCreate(file, UriKind.Absolute, out url))
            {
                try
                {

                    var remoteFile = new RemoteFile(url, false);
                    string script = remoteFile.GetFileAsString();
                    script = ProcessScript(script, file, minify);
                    HttpContext.Current.Cache.Insert(cacheKey, script, null, Cache.NoAbsoluteExpiration, new TimeSpan(3, 0, 0, 0));
                    return script;
                }
                catch (SocketException)
                {
                    // The remote site is currently down. Try again next time.
                }
            }

            return String.Empty;
        }