octopress-syncPost
octopress-syncPost
A octopress plugin to sync post(all posts or latest post) to a website which suport MetaWeblog. (CNBlogs,BlogBus, WordPress etc.)
Configure
- Checkout this repository, copy files in plugins into octopress/plugins/ folder.
-
add new gem denpendencies to Gemfile.
gem 'metaweblog', '~> 0.1.0' gem 'nokogiri', '~> 1.5.9'
<p> (The first gem is used to send post with MetaWeblog API.<br /> The second gem is used to parse html.)<br /> then run <code>bundle install</code> to install them. </li> <li> add this task to Rakefile. </li></ol> <pre>desc "sync latest post to MetaWeblog site"
task :sync_latest_post, :passwd do |t, args| puts “Sync the latest post to MetaWeblog site” if :passwd.nil? system “ruby plugins/sync_latest_post.rb " + args[:passwd] else system “ruby plugins/sync_latest_post.rb” end end
desc “sync all posts to MetaWeblog site(s)” task :sync_all_posts, :passwd do |t, args| puts “Sync all posts to MetaWeblog site(s)” if :passwd.nil? system “ruby plugins/sync_all_posts.rb " + args[:passwd] else system “ruby plugins/sync_all_posts.rb” end end
desc “sync posts after date to MetaWeblog site(s)” task :sync_posts_after_date, :date, :passwd do |t, args| puts “Sync posts after date to MetaWeblog site(s)” if :passwd.nil? system “ruby plugins/sync_posts_after_date.rb "” + args[:date] + "” " + args[:passwd] else system “ruby plugins/sync_posts_after_date.rb "” + args[:date] + "”" end end
desc “sync post by title to MetaWeblog site(s)” task :sync_post_by_title, :title, :passwd do |t, args| puts “Sync post by title to MetaWeblog site(s)” if :passwd.nil? system “ruby plugins/sync_post_by_title.rb "” + args[:title] + "" " + args[:passwd] else system “ruby plugins/sync_post_by_title.rb "” + args[:title] +""" end end
<ol start="4" dir="auto"> <li> Add blogs configuration to the end of octopress/_config.yml </li> </ol> <pre># MetaWeblog
MetaWeblog: blogName: MetaWeblog_username: YOURUSERNAME MetaWeblog_url: YOURBLOGMETAWEBLOGURL MetaWeblog_blogid: BlogID //can be any number
<p> It supports to post to multiple websites at once. There are examples in the file. </p> <pre>#MetaWeblog:
MetaWeblog: Cnblogs: MetaWeblog_username: <yourname> MetaWeblog_url: http://www.cnblogs.com/<yourname>/services/metaweblog.aspx MetaWeblog_blogid: 145005 SINA: MetaWeblog_username: huangbowen521@126.com MetaWeblog_url: http://upload.move.blog.sina.com.cn/blog_rebuild/blog/xmlrpc.php MetaWeblog_blogid: 200000 163blog: MetaWeblog_username: huangbowen521@126.com MetaWeblog_url: http://os.blog.163.com/api/xmlrpc/metaweblog/ MetaWeblog_blogid: 200001
<h2 dir="auto"> <a rel="nofollow noopener" target="_blank" id="user-content-usage" class="anchor" aria-hidden="true" href="#usage"></a>Usage </h2> <ol dir="auto"> <li> run <code>rake generate</code> to generate sites to make all posts brand new. </li> <li> run <code>rake sync_latest_post["PASSWD"]</code> to sync the latest post to your website.<br /> or run <code>rake sync_all_posts["PASSWD"]</code> to sync all posts to your website. <code>PASSWD</code> is your password for the blog sites(It is considered that all your blogs are under the same password). If the <code>PASSWD</code> is omitted, the program will ask you for the password of each blog site. In sync-all way, as time limit from blog site, time gap between each post sending is set to 61 seconds. That may cost some time if you’ve got large sum of posts, It’s your coffee time 😉 </li> <li> run <code>rake sync_posts_after_date["date","PASSWD"]</code> to sync the posts after compare date to your website, <code>date</code> is the date string, some thing like “2013-01-01” or “2013/01/01” or “Jan 1 2013”. </li> <li> run <code>rake sync_post_by_title["title","PASSWD"]</code> to sync a post by the post title to your website. </li> </ol> <p> <strong>Please note:</strong> </p> <ol dir="auto"> <li> Some website require you enable MetaWeblog features in the dashboard. (ect. [cnblogs]) </li> </ol> <h2 dir="auto"> <a rel="nofollow noopener" target="_blank" id="user-content-how-to-keep-same-styling" class="anchor" aria-hidden="true" href="#how-to-keep-same-styling"></a>How to keep same styling </h2> <p> Use [cnblogs] as a example. </p> <ol dir="auto"> <li> use file uploader in cnblogs dashboard to upload screen.css file in your octopress project. </li> <li> config the ‘页首html代码’ in cnblogs dashboard to use the screen.css file. </li> </ol> <p> (Maybe you should adjust the contents to resolve the styling conflict. You can see an example here: <a rel="nofollow noopener" target="_blank" href="http://files.cnblogs.com/huang0925/newScreen.css">http://files.cnblogs.com/huang0925/newScreen.css</a>) </p> <h2 dir="auto"> <a rel="nofollow noopener" target="_blank" id="user-content-some-websites-which-support-metaweblog-api" class="anchor" aria-hidden="true" href="#some-websites-which-support-metaweblog-api"></a>Some websites which support MetaWeblog API. </h2> <ul dir="auto"> <li> Wordpress<br /> If your WordPress root is <a rel="nofollow noopener" target="_blank" href="http://example.com/wordpress/">http://example.com/wordpress/</a>, then you have:<br /> Server: <a rel="nofollow noopener" target="_blank" href="http://example.com/">http://example.com/</a> (some tools need just the ‘example.com’ hostname part)<br /> Path: /wordpress/xmlrpc.php<br /> complete URL (just in case): <a rel="nofollow noopener" target="_blank" href="http://example.com/wordpress/xmlrpc.php">http://example.com/wordpress/xmlrpc.php</a> </li> <li> 51CTO.com<br /> URL:http:///xmlrpc.php(example: <a rel="nofollow noopener" target="_blank" href="http://magong.blog.51cto.com/xmlrpc.php%EF%BC%89">http://magong.blog.51cto.com/xmlrpc.php)</a> </li> <li> 博客大巴<br /> URL:<a rel="nofollow noopener" target="_blank" href="http://www.blogbus.com/">http://www.blogbus.com/</a>/app.php(example: <a rel="nofollow noopener" target="_blank" href="http://www.blogbus.com/holly0801/app.php">http://www.blogbus.com/holly0801/app.php</a> </li> <li> 博客园<br /> URL:<a rel="nofollow noopener" target="_blank" href="http://www.cnblogs.com/">http://www.cnblogs.com/</a>/services/metaweblog.aspx(example: <a rel="nofollow noopener" target="_blank" href="http://www.cnblogs.com/bvbook/services/metaweblog.aspx%EF%BC%89">http://www.cnblogs.com/bvbook/services/metaweblog.aspx)</a> </li> <li> 网易<br /> URL: http://.blog.163.com/ (example: <a rel="nofollow noopener" target="_blank" href="http://huang0925.blog.163.com/">http://huang0925.blog.163.com/</a>). </li> </ul> <h2 dir="auto"> <a rel="nofollow noopener" target="_blank" id="user-content-next-steps" class="anchor" aria-hidden="true" href="#next-steps"></a>Next steps </h2> <p> New features I’d like to add to this plugin: </p> <ul dir="auto"> <li> eliminate duplication when csync_all_posts. </li> <li> Till now, I’ve just tested cnblog. All other metaWeblog supported website should be tested. </li> <li> Code block is not compatible in cnblogs? </li> </ul> <p> Welcome to make suggestions ot contribute to this repo 🙂 </p>