public override string GenerateEditorHtml(IPublishingContext publishingContext) { string status = GenerateStatus(((IContentSourceSite)publishingContext).DialogOwner, ((IContentSourceSite)publishingContext).AccountId); // If the status has changed we need to show it to the user if (status != String.Empty && status != _content.Properties.GetString(VIDEO_STATUS, null)) { using (Bitmap image = CreateMockPlayer(status)) { if (image != null) { // Save this new status _content.Properties.SetString(VIDEO_STATUS, status); UpdateVideoSnapshot(image); } } } StringBuilder html = new StringBuilder(); html.Append(GenerateEditorVideoHtml()); html.Append(GenerateMetadataHtml(((IEditingMode)publishingContext).CurrentEditingMode == EditingMode.Wysiwyg)); return(html.ToString()); }
public VideoContext(IPublishingContext context) { _embeddable = context.SupportsEmbeds; _scriptable = context.SupportsScripts; _blogProviderId = ((BlogPostHtmlEditor)context).ProviderId; _context = context; }
public override bool OnPrePublish(IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { var info = (BlogPost) publishingContext.PostInfo; //look at the publish date. if (!info.HasDatePublishedOverride) { var nextPubDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); nextPubDate = GetNextDayOccurrence(DayOfWeek.Tuesday, nextPubDate); var reader = new JsonTextReader(reader: File.OpenText("Plugins\\Throttle.json")); var json = new Newtonsoft.Json.JsonSerializer(); var config = json.Deserialize<Configuration>(reader); var wrapper = new MetaWeblogWrapper(config.Url, config.Username, config.Password); List<Post> recentPosts = wrapper.GetRecentPosts(10).ToList(); while (recentPosts.Any(p => p.DateCreated >= nextPubDate && p.DateCreated < nextPubDate.AddDays(1))) { nextPubDate = GetNextDayOccurrence(DayOfWeek.Tuesday, nextPubDate.AddDays(1)); } var pubDate = new DateTime(nextPubDate.Year, nextPubDate.Month, nextPubDate.Day, 9, 0, 0); info.DatePublished = pubDate; info.DatePublishedOverride = pubDate; } return base.OnPrePublish(dialogOwner, properties, publishingContext, publish); }
private string GenerateLink(ISmartContent smartContent, IPublishingContext publishingContext, out Position position) { position = Position.Footer; string culture = Thread.CurrentThread.CurrentCulture.Name; if (culture.Contains("-")) culture = culture.Replace("-", "_"); var stringWriter = new StringWriter(); stringWriter.WriteLine("<script type=\"text/javascript\">"); stringWriter.WriteLine("var flattr_uid = '{0}';", _settings.FlattrId); stringWriter.WriteLine("var flattr_tle = '{0}';", publishingContext.PostInfo.Title); stringWriter.WriteLine("var flattr_dsc = '{0}';", publishingContext.PostInfo.Contents); stringWriter.WriteLine("var flattr_cat = 'text';"); stringWriter.WriteLine("var flattr_lng = '{0}';", culture); stringWriter.WriteLine("var flattr_tag = '';"); stringWriter.WriteLine("var flattr_url = '{0}';", publishingContext.PostInfo.Permalink); stringWriter.WriteLine("var flattr_hide = 'false';"); if (_settings.CompactMode) stringWriter.WriteLine("var flattr_btn = 'compact';"); stringWriter.WriteLine("</script>"); stringWriter.WriteLine("<script type=\"text/javascript\" src=\"http://api.flattr.com/button/load.js\"></script>"); return stringWriter.ToString(); }
public override string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { var settings = new Settings(content.Properties); // Always want to embed stylesheet for editor markup. return(settings.Format.FormatCode(settings.SourceCode, embedStylesheet: true, alternate: settings.HighlightAlternateLines, lineNumbers: settings.ShowLineNumbers)); }
/// <summary> /// Notifies the plugin that a blog post was successfully published. /// </summary> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post was posted as a draft.</param> public virtual void OnPostPublish( IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { }
/// <summary> /// Notifies the plugin that a blog post was successfully published. /// </summary> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post was posted as a draft.</param> public virtual void OnPostPublish( IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { }
public VideoContext(IPublishingContext context) { _embeddable = context.SupportsEmbeds; _scriptable = context.SupportsScripts; _blogProviderId = ((BlogPostHtmlEditor)context).ProviderId; _context = context; }
/// <summary> /// Notifies the plugin that a post publish operation is about to be attempted, /// unless this plugin or another publishing notification plugin cancels the /// attempt. /// </summary> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post is being posted as a draft.</param> /// <returns>False to cancel the publish operation, otherwise true.</returns> public virtual bool OnPrePublish( IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { return(true); }
public override string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { VideoSmartContent VideoContent = new VideoSmartContent(content); string html = VideoContent.GenerateEditorHtml(publishingContext); ((IInternalContent)content).RefreshCallback = VideoContent.GetRefreshCallback(); return(html); }
/// <summary> /// Notifies the plugin that a post publish operation is about to be attempted, /// unless this plugin or another publishing notification plugin cancels the /// attempt. /// </summary> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="properties">Property-set that the plugin can use to get and set properties for this post.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post is being posted as a draft.</param> /// <returns>False to cancel the publish operation, otherwise true.</returns> public virtual bool OnPrePublish( IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { return true; }
public override string GeneratePublishHtml(IPublishingContext publishingContext) { VideoContext context = new VideoContext(publishingContext); StringBuilder html = new StringBuilder(); html.Append(GeneratePublishVideoHtml(context)); html.Append(GenerateMetadataHtml(false)); return(html.ToString()); }
public override string GeneratePreviewHtml(ISmartContent smartContent, IPublishingContext publishingContext, out Position position) { string url = publishingContext.PostInfo.Permalink; if (string.IsNullOrEmpty(url)) { url = DotNetShoutoutCounterGenerator.BaseUrl; } return(GenerateLink(url, publishingContext.PostInfo.Title, out position)); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { if (!content.Properties.Contains("html")) { content.Properties["html"] = GenerateHtml( content.Properties["code"], content.Properties["language"], content.Properties["style"]); } return(content.Properties["html"]); }
public override bool OnPrePublish(System.Windows.Forms.IWin32Window dialogOwner, IProperties properties, IPublishingContext publishingContext, bool publish) { bool Result = false; //用于告诉Live Writer是否要post到当前帐户 if (Posting) return true; //由于向Server执行Post操作(IBlogClient.NewPost)会递归调用此过程,所以此处需要屏蔽后续的进入尝试 BlogPost postinfo = publishingContext.PostInfo as BlogPost; BlogPostCategory[] categories = null;// = postinfo.Categories.Clone() as BlogPostCategory[]; //选择帐户 DialogBlogSelect.InitCategorys((publishingContext.PostInfo as WindowsLive.Writer.Extensibility.BlogClient.BlogPost).Categories); if (DialogBlogSelect.ShowDialog() != System.Windows.Forms.DialogResult.OK) { Posting = false; return false; } //排除当前帐户——当前帐户让Live Writer去完成 for (int i = 0; i < DialogBlogSelect.SelectedBlogs.Count; i++) { if (DialogBlogSelect.SelectedBlogs[i].ID.ToString() == publishingContext.AccountId) { postinfo.Categories = DialogBlogSelect.SelectedBlogs[i].PostCatalogs.ToArray(); DialogBlogSelect.SelectedBlogs.RemoveAt(i); Result = true; break; } } //发送到选择的所有帐户——所有的Post操作共用一个PostInfo对象,需要先备份PostInfo中的目录列表 if(Result) { categories = postinfo.Categories.Clone() as BlogPostCategory[]; } foreach (AccountItem blog in DialogBlogSelect.SelectedBlogs) { string str; XmlDocument document; BlogSettings settings = BlogSettings.ForBlogId(blog.ID); IBlogClient client = BlogClientManager.CreateClient(settings); postinfo.Categories = blog.PostCatalogs.ToArray(); string postId = client.NewPost(settings.HostBlogId, postinfo, NullNewCategoryContext.Instance, true, out str, out document); OpenPostedPage(settings.HomepageUrl, postinfo.Permalink); } //恢复目录列表 if(Result) { postinfo.Categories = categories; } Posting = false; return Result; }
public BlogPostEditingManager(IBlogPostEditingSite editingSite, IBlogPostEditor[] postEditors, IPublishingContext publishingContext) { // save reference to owner _mainFrameWindow = editingSite.FrameWindow; _publishingContext = publishingContext; // subscribe to weblog settings edited _editingSite = editingSite; _editingSite.GlobalWeblogSettingsChanged += new WeblogSettingsChangedHandler(editingSite_GlobalWeblogSettingsEdited); // initialize post editors _postEditors.Add(_forceDirtyPostEditor); _postEditors.AddRange(postEditors); }
internal static void PlainTextTransform(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content) { if (source is IInternalSmartContentSource) { try { content = ((IInternalSmartContentSource)source).GeneratePlainTextHtml(sContent, site); } catch (Exception ex) { Trace.WriteLine("Content Source failed to generate plain text html: " + ex); Trace.Flush(); throw; } } }
/// <summary> /// Generate the HTML that should be inserted at the beginning or end of /// the blog post when the editor is switched to Preview mode. /// </summary> /// <remarks> /// The returned HTML will be wrapped inside a <c>div</c> /// whose float and margins can be controlled by the <c>Layout</c> /// property on the <c>ISmartContent</c> parameter. /// </remarks> /// <param name="smartContent">Can be used to get/set properties for this post, add files for upload, and control the layout of the containing <c>div</c>.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="position">The position where the generated HTML should be inserted.</param> /// <returns>The HTML that should appear at the end of the blog post.</returns> public abstract string GeneratePreviewHtml( ISmartContent smartContent, IPublishingContext publishingContext, out Position position);
/// <summary> /// Generate the HTML content which is published to the destination weblog. /// </summary> /// <param name="content">SmartContent object to generate HTML for.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <returns>HTML to be published to the destination weblog.</returns> public abstract string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext);
public override string GenerateEditorHtml(IPublishingContext publishingContext) { string status = GenerateStatus(((IContentSourceSite)publishingContext).DialogOwner, ((IContentSourceSite)publishingContext).AccountId); // If the status has changed we need to show it to the user if (status != String.Empty && status != _content.Properties.GetString(VIDEO_STATUS, null)) { using (Bitmap image = CreateMockPlayer(status)) { if (image != null) { // Save this new status _content.Properties.SetString(VIDEO_STATUS, status); UpdateVideoSnapshot(image); } } } StringBuilder html = new StringBuilder(); html.Append(GenerateEditorVideoHtml()); html.Append(GenerateMetadataHtml(((IEditingMode)publishingContext).CurrentEditingMode == EditingMode.Wysiwyg)); return html.ToString(); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { var settings = new Settings(content.Properties); return settings.Format.FormatCode(settings.SourceCode, embedStylesheet: settings.EmbedStylesheet, alternate: settings.HighlightAlternateLines, lineNumbers: settings.ShowLineNumbers); }
/// <summary> /// Generate the HTML that should be inserted at the beginning or end of /// the blog post when the editor is switched to Preview mode. /// </summary> /// <remarks> /// The returned HTML will be wrapped inside a <c>div</c> /// whose float and margins can be controlled by the <c>Layout</c> /// property on the <c>ISmartContent</c> parameter. /// </remarks> /// <param name="smartContent">Can be used to get/set properties for this post, add files for upload, and control the layout of the containing <c>div</c>.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="position">The position where the generated HTML should be inserted.</param> /// <returns>The HTML that should appear at the end of the blog post.</returns> public abstract string GeneratePreviewHtml( ISmartContent smartContent, IPublishingContext publishingContext, out Position position);
public abstract string GenerateEditorHtml(IPublishingContext publishingContext);
internal static void PlainTextTransform(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content) { if (source is IInternalSmartContentSource) { try { content = ((IInternalSmartContentSource)source).GeneratePlainTextHtml(sContent, site); } catch (Exception ex) { Trace.WriteLine("Content Source failed to generate plain text html: " + ex); Trace.Flush(); throw; } } }
/// <summary> /// Generate the HTML that should be inserted at the beginning or end of /// the blog post during publishing. /// </summary> /// <remarks> /// The returned HTML will be wrapped inside a <c>div</c> /// whose float and margins can be controlled by the <c>Layout</c> /// property on the <c>ISmartContent</c> parameter. /// </remarks> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="smartContent">Can be used to get/set properties for this post, add files for upload, and control the layout of the containing <c>div</c>.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post is being posted as a draft.</param> /// <param name="position">The position where the generated HTML should be inserted.</param> /// <returns>The HTML that should appear at the end of the blog post.</returns> public abstract string GeneratePublishHtml( IWin32Window dialogOwner, ISmartContent smartContent, IPublishingContext publishingContext, bool publish, out Position position);
private void GetStructuredEditorHtml(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content) { using (new SmartContentForceInvalidateNotify(sContent)) content = source.GenerateEditorHtml(sContent, site); }
private void GetStructuredPublishHtml(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content) { content = source.GeneratePublishHtml(sContent, site); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { if (!content.Properties.Contains("html")) { content.Properties["html"] = GenerateHtml( content.Properties["code"], content.Properties["language"], content.Properties["style"]); } return content.Properties["html"]; }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { return string.Format("<pre class=\"{1}\">{0}</pre>", content.Properties["code"], content.Properties["class"]); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { VideoSmartContent VideoContent = new VideoSmartContent(content); return(VideoContent.GeneratePublishHtml(publishingContext)); }
internal void DoPublishWork(IPublishingContext site, SmartContentSource source, ISmartContent sContent, ref string content) { if (source is IPublishTimeWorker) { try { // For each piece of IPublishTimeWorker smart content we find we need to ask if it has // work to do while publishing. We pass null as the external context because that object // is only for use when providing external code a chance to interact with the publish. content = ((IPublishTimeWorker)source).DoPublishWork(_form, sContent, _blog.Id, site, null); } catch (WebException ex) { HttpRequestHelper.LogException(ex); _exception = ex; throw; } catch (Exception ex) { Trace.WriteLine("Content Source failed to do publish work: " + ex); _exception = ex; throw; } } }
public abstract string GeneratePublishHtml(IPublishingContext publishingContext);
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { _currentBlogId = publishingContext.AccountId; return FormTagLinks(content); }
/// <summary> /// Generates HTML for the publishing mode /// </summary> /// <param name="content">Smart content object</param> /// <param name="publishingContext">Publishing context</param> /// <returns>Html</returns> public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { // Get non-default options EffectiveOption[] options = DC.Crayon.Wlw.Framework. Options.GetEffectiveOptions(content.Properties, Options) .Where(p => p.Location != OptionLocation.Default) .ToArray(); // Html Element HtmlElement preElement = new HtmlElement() { Tag = "pre" }; OrderedDictionary classAttrParts = new OrderedDictionary(StringComparer.Ordinal); OrderedDictionary styleAttr = new OrderedDictionary(StringComparer.Ordinal); // Decode classAttrParts["decode"] = "true"; // Setting Groups ApplyContentSettings(false, preElement, classAttrParts, styleAttr, options); ApplyMetricsSettings(false, preElement, classAttrParts, styleAttr, options); ApplyToolbarSettings(true, preElement, classAttrParts, styleAttr, options); ApplyLinesSettings(true, preElement, classAttrParts, styleAttr, options); ApplyCodeSettings(true, preElement, classAttrParts, styleAttr, options); // Set Class if (classAttrParts.Count > 0) { preElement.Attributes["class"] = string.Join(" ", classAttrParts.Cast<DictionaryEntry>() .Select(kv => string.Format(CultureInfo.InvariantCulture, "{0}:{1}", kv.Key, HtmlElement.EscapeAttributeValue(kv.Value.ToString()))) .ToArray()); } // Return return preElement.ToString(); }
public override string GeneratePublishHtml(IWin32Window dialogOwner, ISmartContent smartContent, IPublishingContext publishingContext, bool publish, out Position position) { if (string.IsNullOrEmpty(publishingContext.PostInfo.Permalink)) { Debug.Fail("No permalink!"); position = Position.Footer; return(string.Empty); } return(GenerateLink(publishingContext.PostInfo.Permalink, publishingContext.PostInfo.Title, out position)); }
/// <summary> /// Generate the HTML that should be inserted at the beginning or end of /// the blog post during publishing. /// </summary> /// <remarks> /// The returned HTML will be wrapped inside a <c>div</c> /// whose float and margins can be controlled by the <c>Layout</c> /// property on the <c>ISmartContent</c> parameter. /// </remarks> /// <param name="dialogOwner">Owner for any dialog boxes shown.</param> /// <param name="smartContent">Can be used to get/set properties for this post, add files for upload, and control the layout of the containing <c>div</c>.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <param name="publish">If false, the post is being posted as a draft.</param> /// <param name="position">The position where the generated HTML should be inserted.</param> /// <returns>The HTML that should appear at the end of the blog post.</returns> public abstract string GeneratePublishHtml( IWin32Window dialogOwner, ISmartContent smartContent, IPublishingContext publishingContext, bool publish, out Position position);
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { _currentBlogId = publishingContext.AccountId; return(FormTagLinks(content)); }
/// <summary> /// Generate the HTML content which is published to the destination weblog. /// </summary> /// <param name="content">SmartContent object to generate HTML for.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <returns>HTML to be published to the destination weblog.</returns> public abstract string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext);
public override string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { VideoSmartContent VideoContent = new VideoSmartContent(content); string html = VideoContent.GenerateEditorHtml(publishingContext); ((IInternalContent)content).RefreshCallback = VideoContent.GetRefreshCallback(); return html; }
public override string GeneratePublishHtml(IWin32Window dialogOwner, ISmartContent smartContent, IPublishingContext publishingContext, bool publish, out Position position) { return GenerateLink(smartContent, publishingContext, out position); }
/// <summary> /// Generate the HTML content which is used to represent the SmartContent item within /// the post editor. The default behavior for this method if it is not overridden is to /// call GeneratePublishHtml. /// </summary> /// <param name="content">SmartContent object to generate HTML for.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <returns>HTML content to be inserted into the post editor.</returns> public virtual string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { return(GeneratePublishHtml(content, publishingContext)); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { VideoSmartContent VideoContent = new VideoSmartContent(content); return VideoContent.GeneratePublishHtml(publishingContext); }
public override string GeneratePreviewHtml(ISmartContent smartContent, IPublishingContext publishingContext, out Position position) { return GenerateLink(smartContent, publishingContext, out position); }
public override string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { return GenerateHtml(content, true, publishingContext.AccountId); }
public override string GeneratePublishHtml(IPublishingContext publishingContext) { VideoContext context = new VideoContext(publishingContext); StringBuilder html = new StringBuilder(); html.Append(GeneratePublishVideoHtml(context)); html.Append(GenerateMetadataHtml(false)); return html.ToString(); }
public abstract string GenerateEditorHtml(IPublishingContext publishingContext);
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { var settings = new Settings(content.Properties); return(settings.Format.FormatCode(settings.SourceCode, embedStylesheet: settings.EmbedStylesheet, alternate: settings.HighlightAlternateLines, lineNumbers: settings.ShowLineNumbers)); }
public override string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { return(GenerateHtml(content, true, publishingContext.AccountId)); }
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { return(GenerateHtml(content, false, publishingContext.AccountId)); }
/// <summary> /// Generate the HTML content which is used to represent the SmartContent item within /// the post editor. The default behavior for this method if it is not overridden is to /// call GeneratePublishHtml. /// </summary> /// <param name="content">SmartContent object to generate HTML for.</param> /// <param name="publishingContext">Publishing context for HTML generation.</param> /// <returns>HTML content to be inserted into the post editor.</returns> public virtual string GenerateEditorHtml(ISmartContent content, IPublishingContext publishingContext) { return GeneratePublishHtml(content, publishingContext); }
public abstract string GeneratePublishHtml(IPublishingContext publishingContext);
public override string GeneratePublishHtml(ISmartContent content, IPublishingContext publishingContext) { return GenerateHtml(content, false, publishingContext.AccountId); }