diff options
Diffstat (limited to 'script')
-rw-r--r--[-rwxr-xr-x] | script/export.rb (renamed from script/export_articles.rb) | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/script/export_articles.rb b/script/export.rb index d9f9006..2fc6f4b 100755..100644 --- a/script/export_articles.rb +++ b/script/export.rb @@ -15,13 +15,23 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -output_dir = "_posts" +require 'fileutils' + +output_dir = "export" + +FileUtils.mkdir(output_dir) +IO.write(File.join(output_dir, '_users.yml'), Refinery::User.all.to_yaml) +IO.Write(File.join(output_dir, '_categories.yml'), Refinery::Categories.all.to_yaml) + +posts_dir = File.join(output_dir, '_posts') + +FileUtils.mkdir_p(posts_dir) Refinery::Blog::Post.all.each do |post| filename = "#{post.published_at.to_date}-#{post.slug}.html" puts filename - File.open(File.join(output_dir, filename), "w", 0744) do |f| + File.open(File.join(posts_dir, filename), "w", 0744) do |f| f.write "---\n" f.write "title: #{post.title}\n" f.write "published_at: #{post.published_at}\n" @@ -30,6 +40,8 @@ Refinery::Blog::Post.all.each do |post| f.write "post_id: #{post.id}\n" f.write "draft: #{post.draft}\n" f.write "user_id: #{post.user_id}\n" + f.write "author: #{post.author.username}\n" + f.write "categories: #{post.categories}\n" f.write "custom_teaser: #{post.custom_teaser}\n" f.write "---\n\n" f.write post.body |