meta 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- meta (0.0.3)
4
+ meta (0.0.4)
5
5
  colorize (~> 0.6.0)
6
6
  haml (~> 4.0.4)
7
7
  highline (~> 1.6.20)
@@ -12,7 +12,6 @@ PATH
12
12
  thin (~> 1.6.1)
13
13
  thor (~> 0.18.1)
14
14
  tilt (~> 2.0.0)
15
- url2thumb
16
15
 
17
16
  GEM
18
17
  remote: https://rubygems.org/
@@ -34,7 +33,6 @@ GEM
34
33
  rack (>= 1.0.0)
35
34
  thor (0.18.1)
36
35
  tilt (2.0.0)
37
- url2thumb (0.0.1)
38
36
 
39
37
  PLATFORMS
40
38
  ruby
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # meta compiler (meta)
1
+ # meta
2
2
 
3
3
  ## introduction
4
4
  meta is an opinionated static site generator used to compile haml templates
@@ -9,7 +9,7 @@ having to deploy into production.
9
9
 
10
10
  ## requirements
11
11
  * linux (tested on ubuntu 12.04.x lts)
12
- * ruby (1.9.2+)
12
+ * ruby (1.9.3+)
13
13
  * bundler
14
14
  * colorize
15
15
  * haml
@@ -22,7 +22,6 @@ having to deploy into production.
22
22
  * thor
23
23
  * tilt
24
24
  * url2thumb
25
- * yaml
26
25
 
27
26
  ## installation
28
27
  ```gem install meta```
data/Rakefile CHANGED
@@ -26,6 +26,17 @@ namespace :db do
26
26
 
27
27
  end
28
28
 
29
+ desc "seed database"
30
+ task :seed do
31
+
32
+ Sequel::Fixture.path = File.join( File.dirname(__FILE__), "db/fixtures" )
33
+ conn = Sequel.sqlite(DB)
34
+ fixture = Sequel::Fixture.new :initial, conn
35
+
36
+ fixture.push
37
+
38
+ end
39
+
29
40
  end
30
41
 
31
42
  desc "help"
@@ -0,0 +1,50 @@
1
+ Sequel.migration do
2
+
3
+ up do
4
+
5
+ create_table(:layouts) do
6
+ primary_key :id
7
+ String :path, :null => false
8
+ String :hash, :unique => true
9
+ Time :created_at, :default => Time.now
10
+ Time :updated_at, :default => Time.now
11
+ end
12
+
13
+ create_table(:navbars) do
14
+ primary_key :id
15
+ String :path, :null => false
16
+ String :hash, :unique => true
17
+ Time :created_at, :default => Time.now
18
+ Time :updated_at, :default => Time.now
19
+ end
20
+
21
+ create_table(:pages) do
22
+ primary_key :id
23
+ String :path, :null => false
24
+ String :hash, :unique => true
25
+ Time :created_at, :default => Time.now
26
+ Time :updated_at, :default => Time.now
27
+ end
28
+
29
+ create_table(:footers) do
30
+ primary_key :id
31
+ String :path, :null => false
32
+ String :hash, :unique => true
33
+ Time :created_at, :default => Time.now
34
+ Time :updated_at, :default => Time.now
35
+ end
36
+
37
+
38
+ end
39
+
40
+ down do
41
+
42
+ drop_table(:layouts)
43
+ drop_table(:navbars)
44
+ drop_table(:pages)
45
+ drop_table(:footers)
46
+
47
+ end
48
+
49
+ end
50
+
@@ -0,0 +1,26 @@
1
+ Sequel.migration do
2
+
3
+ up do
4
+
5
+ alter_table(:contents) do
6
+ add_foreign_key :layout_id, :layouts
7
+ add_foreign_key :navbar_id, :navbars
8
+ add_foreign_key :page_id, :pages
9
+ add_foreign_key :footer_id, :footers
10
+ end
11
+
12
+ end
13
+
14
+ down do
15
+
16
+ alter_table(:contents) do
17
+ drop_foreign_key :layout_id
18
+ drop_foreign_key :navbar_id
19
+ drop_foreign_key :page_id
20
+ drop_foreign_key :footer_id
21
+ end
22
+
23
+ end
24
+
25
+ end
26
+
Binary file
@@ -1,21 +1,22 @@
1
1
  open:
2
2
  + custom templates
3
- + referencing a link and commenting on that
4
3
  + post tags
5
4
  + rss/atom feed
6
5
  + config file based configuration
7
- + pull content from other sinks like facebook, flickr, twitter, wechat, etc
8
- + links
6
+ + migrate schema and data
7
+ + remove from catalog if the file no longer exists
8
+ + stats for single page counting incorrectly
9
9
 
10
10
  iced:
11
11
  + syntax highlighting for code
12
+ + pull content from other sinks like facebook, flickr, twitter, wechat, etc
12
13
  + support uppercase file extensions
13
- + migrate schema without losing any data
14
14
  + detect and compile changes only
15
15
  + tie static files with source repository
16
16
  + clone template files
17
17
  + crop articles
18
18
  + .haml files all expected to be in current directory along with .md files
19
+ + links
19
20
 
20
21
  closed:
21
22
  + create index of articles
@@ -30,4 +31,4 @@ closed:
30
31
  + google analytics
31
32
  + title modification
32
33
  + statistics
33
-
34
+ + referencing a link and commenting on that
@@ -103,3 +103,46 @@ markdown compendium:
103
103
 
104
104
  [![alt text](image link)](web link)
105
105
 
106
+
107
+ the url capture feature is too complicated, first it requires native
108
+ dependencies libqt4, xorg or xvfb, and another project that i created
109
+ called url2thumb. second, it overly complicates the simplicity that
110
+ meta started with, the ability to customize via the rich template
111
+ languages. i also thought a use case would be to show all links as
112
+ a thumbnail, but that's just going to cause more photos to be stored
113
+ on the server. so to keep things as lightweight as possible, i think
114
+ a better feature would be to pull things from external sources like
115
+ flickr, picassa, or even facebook if you have access. i'd like to
116
+ create a plugin architecture to allow for these different plugins.
117
+
118
+ a new column was added in the most recent database
119
+
120
+ database migration
121
+
122
+ the migrations in sequel basically allow you to change schema, but i'd like
123
+ to also update or clean data in the table.
124
+
125
+ potential scenarios:
126
+
127
+ 1. Contains an old database with old schema
128
+
129
+ 2. Contains a new database with the latest schema
130
+
131
+ ==============
132
+
133
+ each page should have the following:
134
+
135
+ 1. layout
136
+ 2. page
137
+ 3. navbar*
138
+ 4. footer*
139
+
140
+ * - optional
141
+
142
+ throwing out older versions of meta, they're not ready, plus the migration
143
+ of the database is causing lots of issues.
144
+
145
+ also, i'd like to focus more on a web gui to frontend the database instead of
146
+ using the command line which will help to make sites more manageable over time,
147
+ especially large sites.
148
+
@@ -18,29 +18,37 @@ require File.join( File.dirname(__FILE__), "meta", "filelib" )
18
18
  require File.join( File.dirname(__FILE__), "meta", "page" )
19
19
  require File.join( File.dirname(__FILE__), "meta", "version" )
20
20
 
21
- # macro-like used to keep haml compatibility
22
- def haml(file)
23
- return Tilt.new("#{file}.haml").render
24
- end
25
-
26
21
  module Meta
27
22
 
28
23
  BASEDIR = ".".freeze
29
- CONFIGFILE = "~/.meta".freeze
24
+ CONFIGFILE = File.expand_path("~/.meta")
30
25
  DATASTORE = File.join( Dir.pwd, "site.sqlite3" )
31
26
  EXCLUDES = [ "layout.haml", "navbar.haml", "footer.haml" ]
32
27
  FEXISTS = "File already exists".freeze
28
+ FOOTER = "footers/footer.haml".freeze
29
+ FOOTERS = "footers/*.haml".freeze
33
30
  HAML = ["*.haml"]
34
31
  HAMLEXT = ".haml".freeze
35
32
  HTML = ["*.html"]
36
33
  HTMLEXT = ".html".freeze
37
- INDEX = "index.html".freeze
34
+ INDEX = "pages/index.haml".freeze
35
+ LAYOUT = "layouts/layout.haml".freeze
36
+ LAYOUTS = "layouts/*.haml".freeze
38
37
  MARKDOWN = ["*.md", "*.markdown", "*.mkd"]
39
38
  MDEXT = ".md".freeze
39
+ NAVBAR = "navbar/navbar.haml".freeze
40
+ NAVBARS = "navbars/*.haml".freeze
41
+ PAGE = "pages/page.haml".freeze
42
+ PAGES = "pages/*.haml".freeze
40
43
  PNGEXT = ".png".freeze
44
+ REQUIRED = [ "index.haml", "layout.haml", "page.haml" ]
45
+ SAMPLE = "sample.md".freeze
41
46
  SEED = 1234562
47
+ SKELETONDIRS = [ "footers", "layouts", "navbars", "pages" ]
42
48
  SLASH = "/".freeze
43
49
  SPACE = " ".freeze
44
50
 
51
+ Sequel.extension :migration
52
+
45
53
  end
46
54
 
@@ -2,12 +2,21 @@ module Meta
2
2
 
3
3
  class Catalog
4
4
 
5
- attr_accessor :db
5
+ attr_accessor :db, :resources
6
6
 
7
7
  def initialize
8
8
 
9
9
  self.db = Sequel.sqlite(Meta::DATASTORE)
10
-
10
+
11
+ end
12
+
13
+ def self.upgrade
14
+
15
+ db = Sequel.sqlite(Meta::DATASTORE)
16
+
17
+ Sequel::Migrator.run( db, File.join( File.dirname(__FILE__),
18
+ "../../db/migrate" ) )
19
+
11
20
  end
12
21
 
13
22
  def get_statistics
@@ -51,6 +60,7 @@ module Meta
51
60
  end
52
61
 
53
62
  rs.each do |r|
63
+
54
64
  content = Tilt.new(r[:path]).render
55
65
 
56
66
  content = "abc" if content.empty?
@@ -59,42 +69,113 @@ module Meta
59
69
  r[:link] = File.basename( r[:path], File.extname(r[:path]) ) +
60
70
  HTMLEXT
61
71
  r[:picture] = false
72
+
62
73
  end
63
74
 
64
75
  return rs
65
76
 
66
77
  end
67
78
 
68
- def check_content(content)
79
+ def get_template( template, id )
80
+
81
+ rs = self.db[template.to_sym].where(:id => id).first
82
+
83
+ if rs.nil?
84
+ return nil
85
+ else
86
+ return rs[:path]
87
+ end
88
+
89
+ end
90
+
91
+ def get_resource(template)
92
+
93
+ dir = File.dirname(template)
94
+
95
+ r = self.db[:resources].where(:folder => dir).first()
96
+
97
+ if r.nil?
98
+ return nil
99
+ else
100
+ return r[:id]
101
+ end
102
+
103
+ end
69
104
 
70
- hash = Digest::MD5.hexdigest(content)
105
+ def select_template(template)
106
+
107
+ rs = self.db[template.to_sym].all
108
+
109
+ return rs[0][:id] if rs.count == 1
110
+ return nil if rs.empty?
111
+
112
+ choose do |menu|
113
+
114
+ menu.prompt = "Choose #{template}: "
115
+ rs.each do |r|
116
+ menu.choice File.basename(r[:path]) do return r[:id] end
117
+ end
118
+
119
+ end
120
+
121
+ end
122
+
123
+ def sync_content(content)
124
+
125
+ hash = Digest::MD5.hexdigest(File.read(content))
71
126
 
72
127
  if content_exists?(content)
73
128
  revise_content( content, hash )
74
129
  else
75
- title = ask "Please add a Title for #{content}? "
76
- add_content( content, title, hash )
130
+ add_content( content, hash )
77
131
  end
78
132
 
79
- return self.db[:contents].where(:hash => hash).first()
133
+ rs = self.db[:contents].where(:hash => hash).first
134
+
135
+ return rs
80
136
 
81
137
  end
82
138
 
83
- def add_content( file, title, hash )
139
+ def add_content( file, hash )
140
+
141
+ title = ask "Please add a Title for #{file}? "
142
+
143
+ layout = select_template("layouts")
144
+ navbar = select_template("navbars")
145
+ # leave pages out for now, just default to page.haml
146
+ #page = select_template("pages")
147
+ footer = select_template("footers")
84
148
 
85
149
  self.db[:contents].insert(
86
150
  :title => title,
87
151
  :hash => hash,
88
152
  :path => file,
153
+ :layout_id => layout,
154
+ :navbar_id => navbar,
155
+ :page_id => 1,
156
+ :footer_id => footer,
89
157
  :created_at => Time.now )
90
158
 
91
159
  end
92
160
 
93
161
  def revise_content( file, hash )
162
+
163
+ content = self.db[:contents].where(:path => file).first
164
+
165
+ puts "Changes detected for #{file}".yellow if hash != content[:hash]
166
+
167
+ if content[:layout_id].nil?
168
+ # for legacy schema purposes
169
+ puts "Select layout for #{file}:"
170
+ lid = select_template("layouts")
171
+ else
172
+ lid = content[:layout_id]
173
+ end
94
174
 
95
- #puts self.db[:contents].where(:path => file).select(:title).first()[:title]
96
175
  self.db[:contents].where(:path => file).update(
97
176
  :hash => hash,
177
+ :layout_id => lid,
178
+ :page_id => 1,
98
179
  #:title => title,
99
180
  :updated_at => Time.now )
100
181
 
@@ -107,12 +188,12 @@ module Meta
107
188
 
108
189
  end
109
190
 
110
- def check_templates(templates)
191
+ def sync_templates(templates)
111
192
 
112
193
  templates.each do |t|
113
194
 
114
195
  hash = Digest::MD5.hexdigest(t)
115
-
196
+
116
197
  if template_exists?(t)
117
198
 
118
199
  revise_template( t, hash )
@@ -129,7 +210,9 @@ module Meta
129
210
 
130
211
  def add_template( file, hash )
131
212
 
132
- self.db[:templates].insert(
213
+ dir = File.dirname(file)
214
+
215
+ self.db[dir.to_sym].insert(
133
216
  :path => file,
134
217
  :hash => hash )
135
218
 
@@ -137,11 +220,13 @@ module Meta
137
220
 
138
221
  def revise_template( file, hash )
139
222
 
140
- rs = self.db[:templates].where( :hash => hash, :path => file ).first
223
+ dir = File.dirname(file)
224
+
225
+ rs = self.db[dir.to_sym].where( :hash => hash, :path => file ).first
141
226
 
142
227
  if rs.empty?
143
228
 
144
- self.db[:templates].insert(
229
+ self.db[dir.to_sym].insert(
145
230
  :path => file,
146
231
  :hash => hash )
147
232
 
@@ -151,7 +236,9 @@ module Meta
151
236
 
152
237
  def template_exists?(file)
153
238
 
154
- rs = self.db[:templates].where(:path => file).all
239
+ dir = File.dirname(file)
240
+
241
+ rs = self.db[dir.to_sym].where(:path => file).all
155
242
 
156
243
  if rs.empty?
157
244
  return false
@@ -163,7 +250,9 @@ module Meta
163
250
 
164
251
  def template_revised?( path, hash )
165
252
 
166
- rs = self.db[:templates].where( :hash => hash, :path => path )
253
+ dir = File.dirname(path)
254
+
255
+ rs = self.db[dir.to_sym].where( :hash => hash, :path => path )
167
256
 
168
257
  if rs.nil?
169
258
  return true
@@ -3,8 +3,6 @@ module Meta
3
3
  class CLI < Thor
4
4
  include Thor::Actions
5
5
 
6
- config = YAML.load_file(CONFIGFILE) if File.exists?(CONFIGFILE)
7
-
8
6
  desc "compile", "compile meta files"
9
7
  method_option :output, :aliases => "-o", :type => :string,
10
8
  :required => false, :desc => "static file output directory"
@@ -14,6 +12,8 @@ module Meta
14
12
  :required => false, :desc => "don't prompt to overwrite files"
15
13
  def compile
16
14
 
15
+ Meta::Catalog.upgrade
16
+
17
17
  if options[:output].nil?
18
18
  dest = "."
19
19
  else
@@ -30,27 +30,8 @@ module Meta
30
30
  desc "init", "initialize static meta project"
31
31
  def init
32
32
 
33
- f = File.join( File.dirname(__FILE__), "../../db/site.sqlite3" )
34
-
35
- if File.exists?("site.sqlite3")
36
-
37
- puts "Warning: All index data will be lost!".red
38
- reply = agree("Database already exists, overwrite?".red) {
39
- |q| q.default = "n" }
40
-
41
- if reply
42
- FileUtils.cp( f, Dir.pwd )
43
- puts "Database re-initialized".green
44
- else
45
- puts "Database not initialized".red
46
- end
47
-
48
- else
49
-
50
- FileUtils.cp( f, Dir.pwd )
51
- puts "Database initialized".green
52
-
53
- end
33
+ db_init
34
+ create_skeleton
54
35
 
55
36
  end
56
37
 
@@ -98,52 +79,93 @@ module Meta
98
79
 
99
80
  end
100
81
 
101
- desc "capture", "capture thumbnail of url"
102
- method_option :output, :aliases => "-o", :type => :string,
103
- :required => false, :desc => "output directory"
104
- def capture(url)
82
+ default_task :compile
105
83
 
106
- if options[:output].nil?
107
- dest = BASEDIR
108
- else
109
- dest = options[:output]
110
- end
84
+ no_tasks do
111
85
 
112
- images = dest + SLASH + "images"
86
+ def read_config
113
87
 
114
- images = dest unless Dir.exists?(images)
88
+ return YAML.load_file(CONFIGFILE) if File.exists?(CONFIGFILE)
115
89
 
116
- cmd = "xvfb-run url2thumb capture #{url} -o #{images}"
90
+ end
91
+
92
+ def db_init
117
93
 
118
- stdin, stdout, stderr = Open3.popen3(cmd)
94
+ f = File.join( File.dirname(__FILE__), "../../db/site.sqlite3" )
119
95
 
120
- abort( stderr.read.chomp.red ) if stdout.nil?
96
+ if File.exists?("site.sqlite3")
121
97
 
122
- out = stdout.read.chomp
98
+ puts "Warning: All index data will be lost!".red
99
+ reply = agree("Database already exists, overwrite?".red) {
100
+ |q| q.default = "n" }
123
101
 
124
- unless out.include?(FEXISTS)
102
+ if reply
103
+ FileUtils.cp( f, Dir.pwd )
104
+ puts "Database re-initialized".green
105
+ else
106
+ puts "Database not initialized".red
107
+ end
125
108
 
126
- created = out.split(SPACE).first
109
+ else
127
110
 
128
- link = "[![referral](images/#{File.basename(created)})](#{url})"
111
+ FileUtils.cp( f, Dir.pwd )
112
+ puts "Database initialized".green
129
113
 
130
- Meta::Filelib.create_file( link, created, MDEXT, dest, false )
114
+ end
131
115
 
132
116
  end
133
-
134
- end
135
117
 
136
- desc "test", "testing"
137
- def test
118
+ def create_skeleton
138
119
 
139
- c = Meta::Catalog.new
140
- stats = c.get_statistics
141
- puts stats[:posts]
142
- puts stats[:pictures]
143
-
144
- end
120
+ SKELETONDIRS.each do |d|
121
+ Meta::Filelib.create_directory(d)
122
+ end
145
123
 
146
- default_task :compile
124
+ if File.exists?(LAYOUT)
125
+ puts "#{LAYOUT} already exists, file skipped".yellow
126
+ else
127
+ FileUtils.cp( File.join( File.dirname(__FILE__),
128
+ "skeleton/layout.haml" ), "layouts" )
129
+ end
130
+
131
+ if File.exists?(NAVBAR)
132
+ puts "#{NAVBAR} already exists, file skipped".yellow
133
+ else
134
+ FileUtils.cp( File.join( File.dirname(__FILE__),
135
+ "skeleton/navbar.haml" ), "navbars" )
136
+ end
137
+
138
+ if File.exists?(FOOTER)
139
+ puts "#{FOOTER} already exists, file skipped".yellow
140
+ else
141
+ FileUtils.cp( File.join( File.dirname(__FILE__),
142
+ "skeleton/footer.haml" ), "footers" )
143
+ end
144
+
145
+ if File.exists?(INDEX)
146
+ puts "#{INDEX} already exists, file skipped".yellow
147
+ else
148
+ FileUtils.cp( File.join( File.dirname(__FILE__),
149
+ "skeleton/index.haml" ), "pages" )
150
+ end
151
+
152
+ if File.exists?(PAGE)
153
+ puts "#{PAGE} already exists, file skipped".yellow
154
+ else
155
+ FileUtils.cp( File.join( File.dirname(__FILE__),
156
+ "skeleton/page.haml" ), "pages" )
157
+ end
158
+
159
+ if File.exists?(SAMPLE)
160
+ puts "#{SAMPLE} already exists, file skipped".yellow
161
+ else
162
+ FileUtils.cp( File.join( File.dirname(__FILE__),
163
+ "skeleton/sample.md" ), BASEDIR )
164
+ end
165
+
166
+ end
167
+
168
+ end
147
169
 
148
170
  end
149
171
 
@@ -7,7 +7,7 @@ module Meta
7
7
  unless name.nil?
8
8
 
9
9
  if File.directory?(name)
10
- puts "directory already exists"
10
+ puts "directory already exists".yellow
11
11
  else
12
12
  FileUtils.mkdir_p(name)
13
13
  puts "directory #{name} created".green
@@ -50,16 +50,12 @@ module Meta
50
50
 
51
51
  end
52
52
 
53
- def self.get_templates()
54
-
55
- return Dir.glob( Meta::HAML, File::FNM_CASEFOLD )
56
-
53
+ def self.get_templates(pattern)
54
+ return Dir.glob( pattern, File::FNM_CASEFOLD )
57
55
  end
58
56
 
59
- def self.get_contents()
60
-
57
+ def self.get_contents
61
58
  return Dir.glob( Meta::MARKDOWN, File::FNM_CASEFOLD )
62
-
63
59
  end
64
60
 
65
61
  end
@@ -10,29 +10,46 @@ module Meta
10
10
 
11
11
  @catalog = Meta::Catalog.new
12
12
 
13
- @templates = Meta::Filelib.get_templates
13
+ @layouts = Meta::Filelib.get_templates(LAYOUTS)
14
+ @navbars = Meta::Filelib.get_templates(NAVBARS)
15
+ @pages = Meta::Filelib.get_templates(PAGES)
16
+ @footers = Meta::Filelib.get_templates(FOOTERS)
14
17
 
15
- @layout = Tilt.new("layout.haml") if @templates.include?("layout.haml")
16
- @navbar = Tilt.new("navbar.haml") if @templates.include?("navbar.haml")
17
- @index = Tilt.new("index.haml") if @templates.include?("index.haml")
18
- @page = Tilt.new("page.haml") if @templates.include?("page.haml")
18
+ unless @layouts.include?(LAYOUT)
19
+ abort("layout.haml not found, #{LAYOUT}, #{INDEX}, and #{PAGE} must exist".red)
20
+ end
21
+
22
+ unless @pages.include?(INDEX)
23
+ abort("index.haml not found, #{LAYOUT}, #{INDEX}, and #{PAGE} must exist".red)
24
+ end
19
25
 
20
- if @layout.nil?
21
- abort("layout.haml template missing, this file must be included".red)
26
+ unless @pages.include?(PAGE)
27
+ abort("page.haml not found, #{LAYOUT}, #{INDEX}, #{PAGE} must exist".red)
22
28
  end
23
- #TODO: must include index and page as well
29
+
30
+ templates = @layouts | @pages
31
+ templates |= @navbars unless @navbars.nil?
32
+ templates |= @footers unless @footers.nil?
33
+
34
+ @catalog.sync_templates(templates)
35
+
36
+ @index = Tilt.new(INDEX)
37
+ @page = Tilt.new(PAGE)
38
+ @layout = Tilt.new(LAYOUT)
24
39
 
25
40
  end
26
41
 
27
42
  def generate_index(overwrite=false)
28
43
 
29
- contents = @catalog.get_recent(-1)
44
+ contents = @catalog.get_recent(-1)
45
+
46
+ stats = @catalog.get_statistics
30
47
 
31
- stats = @catalog.get_statistics
48
+ doc = @index.render( self, :contents => contents )
32
49
 
33
- doc = @index.render( self, :contents => contents )
50
+ html = @layout.render( self, :stats => stats ) { doc }
34
51
 
35
- html = @layout.render( self, :stats => stats ) { doc }
52
+ puts "If any content has been modified, index.html should be updated.".yellow
36
53
 
37
54
  Meta::Filelib.create_file( html, INDEX, HTMLEXT, @dest, overwrite )
38
55
 
@@ -53,15 +70,21 @@ module Meta
53
70
 
54
71
  end
55
72
 
56
- content = @catalog.check_content(c)
73
+ content = @catalog.sync_content(c)
57
74
 
58
75
  content[:summary] = Tilt.new(c).render
59
76
  content[:link] = File.basename( content[:path],
60
77
  File.extname(content[:path]) ) + HTMLEXT
61
78
 
62
- p = @page.render( self, :content => content )
79
+ layout = @catalog.get_template( "layouts", content[:layout_id] )
80
+ page = @catalog.get_template( "pages", content[:page_id] )
81
+
82
+ @mylayout = Tilt.new(layout)
83
+ @mypage = Tilt.new(page)
84
+
85
+ p = @mypage.render( self, :content => content )
63
86
 
64
- html = @layout.render( self, :stats => stats ) { p }
87
+ html = @mylayout.render( self, :stats => stats ) { p }
65
88
 
66
89
  Meta::Filelib.create_file( html, c, HTMLEXT, @dest, overwrite )
67
90
 
@@ -0,0 +1,3 @@
1
+ %div{:class => "navbar navbar-static-bottom"}
2
+ %p Copyright &copy; 2014
3
+
@@ -0,0 +1,9 @@
1
+ %div{:class => "container"}
2
+ - contents.each do |c|
3
+ %div{:class => "row"}
4
+ %div{:class => "col-lg-12"}
5
+ %a{:href => "#{c[:link]}"}
6
+ %h3= c[:title]
7
+ %date= c[:created_at]
8
+ = c[:summary]
9
+
@@ -0,0 +1,11 @@
1
+ !!!
2
+ %html{:lang => "en"}
3
+ %head
4
+ %title Sample: Meta Generated Site
5
+ %link{:rel => "stylesheet", :href => "//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css"}
6
+ %link{:rel => "stylesheet", :href => "css/stylesheet.css"}
7
+
8
+ %body
9
+
10
+ = yield
11
+
@@ -0,0 +1,12 @@
1
+ %div.navbar.navbar-static-top
2
+ %div.navbar-header
3
+ %a.navbar-brand{:href => "index.html"}
4
+ Sample: Meta Generated Site
5
+ %ul
6
+ %li
7
+ %a{:href => "", :class => "active"} home
8
+ %li
9
+ %a{:href => ""} blog
10
+ %li
11
+ %a{:href => ""} about
12
+
@@ -0,0 +1,5 @@
1
+ %div{:class => "container"}
2
+ %div{:class => "row"}
3
+ %div{:class => "col-lg-12"}
4
+ %p= content[:summary]
5
+
@@ -0,0 +1,2 @@
1
+ This is the first post, hello world!
2
+
@@ -1,4 +1,4 @@
1
1
  module Meta
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
4
4
 
@@ -33,6 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency "bundler", "~> 1.3"
34
34
  spec.add_development_dependency "rake"
35
35
 
36
- spec.add_runtime_dependency "url2thumb"
37
36
  end
38
37
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-11 00:00:00.000000000 Z
12
+ date: 2014-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize
@@ -203,22 +203,6 @@ dependencies:
203
203
  - - ! '>='
204
204
  - !ruby/object:Gem::Version
205
205
  version: '0'
206
- - !ruby/object:Gem::Dependency
207
- name: url2thumb
208
- requirement: !ruby/object:Gem::Requirement
209
- none: false
210
- requirements:
211
- - - ! '>='
212
- - !ruby/object:Gem::Version
213
- version: '0'
214
- type: :runtime
215
- prerelease: false
216
- version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
- requirements:
219
- - - ! '>='
220
- - !ruby/object:Gem::Version
221
- version: '0'
222
206
  description: opinionated static web page generator
223
207
  email:
224
208
  - epynonymous@outlook.com
@@ -239,6 +223,8 @@ files:
239
223
  - db/migrate/002_picture.rb
240
224
  - db/migrate/003_remove_templates.rb
241
225
  - db/migrate/004_remove_fk.rb
226
+ - db/migrate/005_add_layouts.rb
227
+ - db/migrate/006_add_fkey.rb
242
228
  - db/site.sqlite3
243
229
  - docs/backlog
244
230
  - docs/design
@@ -247,6 +233,12 @@ files:
247
233
  - lib/meta/cli.rb
248
234
  - lib/meta/filelib.rb
249
235
  - lib/meta/page.rb
236
+ - lib/meta/skeleton/footer.haml
237
+ - lib/meta/skeleton/index.haml
238
+ - lib/meta/skeleton/layout.haml
239
+ - lib/meta/skeleton/navbar.haml
240
+ - lib/meta/skeleton/page.haml
241
+ - lib/meta/skeleton/sample.md
250
242
  - lib/meta/version.rb
251
243
  - meta.gemspec
252
244
  homepage: http://github.io/stephenhu/meta