to_octopress 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +27 -0
- data/LICENSE.txt +22 -0
- data/README.md +45 -0
- data/Rakefile +9 -0
- data/example/.DS_Store +0 -0
- data/example/example.rb +2 -0
- data/lib/to_octopress/version.rb +3 -0
- data/lib/to_octopress.rb +57 -0
- data/test/test_to_octopress.rb +10 -0
- data/test/to_octopress.zip +0 -0
- data/to_octopress-0.0.1.gem +0 -0
- data/to_octopress.gemspec +26 -0
- metadata +131 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ef360773e8014803389891e112573852e4f9e39f
|
4
|
+
data.tar.gz: e3495053592b2d24d81937bbaa32075fcfae7fca
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d98fa1088efc53257d1638d81eb9062fb84da828482e648d121e2850d6b3b4be4415095c1a24dfa3ac2764b32163fddf65658a2759adbd4f1326d7d2c924dc2
|
7
|
+
data.tar.gz: 219110eddc33acba44720922b4cb81c2e73b4f89ca2ea3c5f52ae78c1fea2c6e91437943bf3058d15e0679e8533f67b2d118570152643c166dd893c4f2c2bf41
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
to_octopress (0.0.1)
|
5
|
+
pg
|
6
|
+
reverse_markdown
|
7
|
+
rubyzip
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
mini_portile (0.6.2)
|
13
|
+
nokogiri (1.6.6.2)
|
14
|
+
mini_portile (~> 0.6.0)
|
15
|
+
pg (0.18.1)
|
16
|
+
rake (10.4.2)
|
17
|
+
reverse_markdown (0.7.0)
|
18
|
+
nokogiri
|
19
|
+
rubyzip (1.1.7)
|
20
|
+
|
21
|
+
PLATFORMS
|
22
|
+
ruby
|
23
|
+
|
24
|
+
DEPENDENCIES
|
25
|
+
bundler (~> 1.5)
|
26
|
+
rake
|
27
|
+
to_octopress!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 rwwaskk
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# ToOctopress
|
2
|
+
|
3
|
+
A simple gem for generating octopress markdown files from PostgreSQL database, useful for migrating your blogging system to octopress from other platforms (e.g Rails)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'to_octopress'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install to_octopress
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
require 'to_octopress'
|
22
|
+
|
23
|
+
ToOctopress.to_octopress(database_name,table_name,timestamp_column,slug_column,content_column,title_column,path_to_zip_file)
|
24
|
+
|
25
|
+
## Example
|
26
|
+
ToOctopress.to_octopress('blogs_database',"blogs","updated_at","slug","content","title",File.dirname(__FILE__))
|
27
|
+
|
28
|
+
|
29
|
+
A file named to_octoress.zip will be generated. It contains the list of markdown files compatible with octopress's name conventions and yaml setup.
|
30
|
+
|
31
|
+
|
32
|
+
## TODO
|
33
|
+
|
34
|
+
Write more test cases
|
35
|
+
|
36
|
+
Support for other databases
|
37
|
+
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
1. Fork it ( http://github.com/<my-github-username>/to_octopress/fork )
|
42
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
43
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
44
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
45
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/example/.DS_Store
ADDED
Binary file
|
data/example/example.rb
ADDED
data/lib/to_octopress.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require "to_octopress/version"
|
2
|
+
require 'pg'
|
3
|
+
require 'reverse_markdown'
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'zip'
|
7
|
+
|
8
|
+
module ToOctopress
|
9
|
+
def self.to_octopress(db_name,table_name,timestamp_name,slug_name,content_name,title_name,current_dir)
|
10
|
+
conn = PGconn.open(:dbname => db_name)
|
11
|
+
query = "SELECT to_char("+timestamp_name+",'YYYY-MM-DD') as updated_at, "+slug_name+" as slug, "+ content_name+" as content, "+title_name +" as title from "+table_name
|
12
|
+
res = conn.exec(query)
|
13
|
+
|
14
|
+
file_names=[]
|
15
|
+
res.each do |entry|
|
16
|
+
|
17
|
+
updated_at= entry['updated_at'] # '1'
|
18
|
+
slug=entry['slug'] # '1'
|
19
|
+
content=entry['content']
|
20
|
+
thetitle = entry['title']
|
21
|
+
|
22
|
+
|
23
|
+
title = current_dir+"/"+updated_at+'-'+slug+'.markdown'
|
24
|
+
markdown_content = ReverseMarkdown.convert content
|
25
|
+
|
26
|
+
File.open(title, "w") do |f|
|
27
|
+
f.write("---\n")
|
28
|
+
f.write("layout: post\n")
|
29
|
+
f.write('title: "'+thetitle+'"')
|
30
|
+
f.write "\n"
|
31
|
+
f.write("date: "+updated_at)
|
32
|
+
f.write "\n"
|
33
|
+
f.write("comments: true\n")
|
34
|
+
f.write("categories: \n")
|
35
|
+
f.write("---\n\n")
|
36
|
+
f.write(markdown_content)
|
37
|
+
file_names<<updated_at+'-'+slug+'.markdown'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
Zip.on_exists_proc = true
|
42
|
+
Zip.continue_on_exists_proc = true
|
43
|
+
|
44
|
+
folder = current_dir
|
45
|
+
zipfile_name = folder+"/to_octopress.zip"
|
46
|
+
|
47
|
+
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
|
48
|
+
file_names.each do |filename|
|
49
|
+
zipfile.add(filename, folder + '/' + filename)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
file_names.each do |filename|
|
54
|
+
File.delete(current_dir+"/"+filename)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'to_octopress'
|
2
|
+
require 'minitest/autorun'
|
3
|
+
|
4
|
+
|
5
|
+
class ToOctopressTest < Minitest::Unit::TestCase
|
6
|
+
def test_to_octopress
|
7
|
+
ToOctopress.to_octopress('shawsome_test',"blogs","updated_at","slug","content","title",File.dirname(__FILE__))
|
8
|
+
assert(true,File.file?('to_octopress.zip'))
|
9
|
+
end
|
10
|
+
end
|
Binary file
|
Binary file
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'to_octopress/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "to_octopress"
|
8
|
+
spec.version = ToOctopress::VERSION
|
9
|
+
spec.authors = ["yunrui zhang"]
|
10
|
+
spec.email = ["yunrui@unary.io"]
|
11
|
+
spec.summary = "Summary"
|
12
|
+
spec.description = "A simple gem for generating octopress markdown files from PostgreSQL database, useful for migrating your blogging system to octopress from other platforms (e.g Rails)"
|
13
|
+
spec.homepage = "https://github.com/rwwaskk/to_octopress"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
21
|
+
spec.add_development_dependency "rake"
|
22
|
+
|
23
|
+
spec.add_dependency "pg"
|
24
|
+
spec.add_dependency "reverse_markdown"
|
25
|
+
spec.add_dependency "rubyzip"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: to_octopress
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- yunrui zhang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pg
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: reverse_markdown
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubyzip
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: A simple gem for generating octopress markdown files from PostgreSQL
|
84
|
+
database, useful for migrating your blogging system to octopress from other platforms
|
85
|
+
(e.g Rails)
|
86
|
+
email:
|
87
|
+
- yunrui@unary.io
|
88
|
+
executables: []
|
89
|
+
extensions: []
|
90
|
+
extra_rdoc_files: []
|
91
|
+
files:
|
92
|
+
- Gemfile
|
93
|
+
- Gemfile.lock
|
94
|
+
- LICENSE.txt
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- example/.DS_Store
|
98
|
+
- example/example.rb
|
99
|
+
- lib/to_octopress.rb
|
100
|
+
- lib/to_octopress/version.rb
|
101
|
+
- test/test_to_octopress.rb
|
102
|
+
- test/to_octopress.zip
|
103
|
+
- to_octopress-0.0.1.gem
|
104
|
+
- to_octopress.gemspec
|
105
|
+
homepage: https://github.com/rwwaskk/to_octopress
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - '>='
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.2.1
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: Summary
|
129
|
+
test_files:
|
130
|
+
- test/test_to_octopress.rb
|
131
|
+
- test/to_octopress.zip
|