Last active
December 18, 2015 18:10
-
-
Save sskylar/5824224 to your computer and use it in GitHub Desktop.
Revisions
-
sskylar revised this gist
Jun 21, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,6 +8,7 @@ # site settings site_id = '...' page_id = '...' # blog page to import posts into test_mode = false # change to true to test your import # get entries from JSON dump contents = JSON.parse(File.read("import-siteleaf.json")) @@ -33,7 +34,7 @@ post.published_at = content["published_at"] # save puts test_mode ? post.inspect : post.save.inspect end # done! -
sskylar revised this gist
Jun 21, 2013 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,12 +10,13 @@ page_id = '...' # blog page to import posts into # get entries from JSON dump contents = JSON.parse(File.read("import-siteleaf.json")) # loop through and add entries contents.each do |content| puts "Creating post..." # set up post post = Siteleaf::Post.new post.site_id = site_id post.parent_id = page_id -
sskylar renamed this gist
Jun 21, 2013 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
sskylar revised this gist
Jun 20, 2013 . 2 changed files with 11 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ [{ "title":"Post 1", "body":"Body goes here.", "tags":["Tag 1", "Tag 2"], "slug":"post-1", "published_at":"2013-06-05T18:24:59-04:00" }, { "title":"Post 2", "body":"Body goes here.", "tags":["Tag 1", "Tag 2"], "slug":"post-2", "published_at":"2013-06-05T18:24:59-04:00" }] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,16 +15,23 @@ contents = JSON.parse(File.read("import.json")) # loop through and add entries contents.each do |content| puts "Creating post..." post = Siteleaf::Post.new post.site_id = site_id post.parent_id = page_id # required post.title = content["title"] post.body = content["body"] # optional post.taxonomy = [ {"key" => "Tags", "values" => content["tags"]} ] post.slug = content["slug"] post.published_at = content["published_at"] # save puts post.save.inspect end -
sskylar revised this gist
Jun 20, 2013 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
File renamed without changes.This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,7 +10,7 @@ site_id = '...' page_id = '...' # blog page to import posts into # get entries from JSON dump contents = JSON.parse(File.read("import.json")) # loop through and add entries contents.each do |content| -
sskylar created this gist
Jun 20, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ [{ "title":"Post 1", "body":"Body goes here.", "slug":"post-1", "tags":["Tag 1", "Tag 2"], "published_at":"2013-06-05T18:24:59-04:00" }, { "title":"Post 2", "body":"Body goes here.", "slug":"post-2", "tags":["Tag 1", "Tag 2"], "published_at":"2013-06-05T18:24:59-04:00" }] This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ require "siteleaf" require "json" # API settings Siteleaf.api_key = '...' Siteleaf.api_secret = '...' # site settings site_id = '...' page_id = '...' # blog page to import posts into # get entries from JSON dump contents = JSON.parse(File.read("export.json")) # loop through and add entries contents.each do |content| puts "Creating post..." post = Siteleaf::Post.new post.site_id = site_id post.parent_id = page_id post.title = content["title"] post.slug = content["slug"] # optional post.body = content["body"] post.taxonomy = [ {"key" => "Tags", "values" => content["tags"]} # optional ] post.published_at = content["published_at"] puts post.save.inspect end # done! puts "Success!"