/// <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); }
/// <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); } } }
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); } } }
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); } } }
/// <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); } } }
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.sourceHasLink = html.ToUpperInvariant().Contains(targetUrl.ToUpperInvariant()); } catch (WebException) { this.sourceHasLink = false; // throw new ArgumentException("Trackback sender does not exists: " + sourceUrl, ex); } }
/// <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); } }
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; } }
/// <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; }
/// <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; }