aboutsummaryrefslogtreecommitdiffstats
path: root/script
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-06-04 14:22:23 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-06-04 14:22:23 +0200
commit5ca6bfad73bec0a2f3b9932c7bedf9d9b50602c0 (patch)
tree77d4cec627d9731e5cc209cefa3d749db4259980 /script
parent026706fbff14ef496fdcd96cf88a7a38a20bf44f (diff)
downloadhmnoweb-5ca6bfad73bec0a2f3b9932c7bedf9d9b50602c0.tar.gz
hmnoweb-5ca6bfad73bec0a2f3b9932c7bedf9d9b50602c0.tar.bz2
hmnoweb-5ca6bfad73bec0a2f3b9932c7bedf9d9b50602c0.zip
Export users + categories in addition to posts
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