Detailed instructions on how to use these scripts coming soon!
Last active
August 29, 2015 14:10
-
-
Save jgarber623/70eea394e58ed320cf1a to your computer and use it in GitHub Desktop.
Useful scripts for converting and preparing data for FrancisCMS.
This file contains 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 characters
links = JSON.load(File.open('/path/to/links.json', 'r')) | |
links.each do |link| | |
FrancisCms::Link.new( | |
url: link['url'], | |
title: link['title'], | |
body: link['comment'], | |
tag_list: link['tags'], | |
published_at: link['add_date'] | |
).save! | |
sleep(1) | |
end |
This file contains 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 characters
filepaths = Dir.glob('/path/to/posts/*.md') | |
filepaths.each do |filepath| | |
yaml = YAML.load_file(filepath) | |
post = FrancisCms::Post.new({ | |
body: IO.read(filepath).split("\n---\n\n")[1..-1].join("\n---\n\n"), | |
published_at: yaml['date'], | |
slug: /\d{4}-\d{2}-\d{2}-(.+?).md/.match(filepath)[1], | |
title: yaml['title'] | |
}) | |
post.excerpt = yaml['excerpt'] unless yaml['excerpt'].nil? | |
post.tag_list = yaml['tags'].join(', ') unless yaml['tags'].nil? | |
unless yaml['copies'].nil? | |
yaml['copies'].each do |copy| | |
post.syndications.new({ name: copy['title'], url: copy['url'] }) | |
end | |
end | |
post.save! | |
sleep(1) | |
end |
This file contains 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 characters
webmentions = JSON.load(File.open('/path/to/webmentions.json', 'r')) | |
webmentions.each do |webmention| | |
FrancisCms::Webmention.new( | |
source: webmention['source'], | |
target: webmention['target'], | |
created_at: webmention['created_at'] | |
).save! | |
sleep(1) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment