grat 0.0.3.1 → 0.0.4

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.
data/Manifest CHANGED
@@ -6,9 +6,7 @@ lib/environment.rb
6
6
  lib/grat.rb
7
7
  lib/grat/content.rb
8
8
  lib/grat/mongomapper_patches.rb
9
- lib/grat/page.rb
10
9
  lib/grat/system.rb
11
- lib/grat/template.rb
12
10
  public/gratfiles/application.js
13
11
  public/gratfiles/custom.css
14
12
  public/gratfiles/einars-js-beautify/HTML-Beautify.js
data/Rakefile CHANGED
@@ -3,8 +3,9 @@ require 'rubygems'
3
3
  require 'rake'
4
4
  require 'echoe'
5
5
 
6
- Echoe.new('grat', '0.0.3.1') do |p|
7
- p.description = "Minimal CMS for Rack and MongoDB."
6
+ Echoe.new('grat', '0.0.4') do |p|
7
+ p.summary = "Minimal CMS for Rack and MongoDB."
8
+ p.description = "Basic interface for making webpages with Haml and (later) erb. Supports nested templates."
8
9
  p.url = "http://samsm.com/"
9
10
  p.author = "Sam Schenkman-Moore"
10
11
  p.email = "samsm@samsm.com"
data/grat.gemspec CHANGED
@@ -2,15 +2,15 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{grat}
5
- s.version = "0.0.3.1"
5
+ s.version = "0.0.4"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Schenkman-Moore"]
9
9
  s.date = %q{2009-11-02}
10
- s.description = %q{Minimal CMS for Rack and MongoDB.}
10
+ s.description = %q{Basic interface for making webpages with Haml and (later) erb. Supports nested templates.}
11
11
  s.email = %q{samsm@samsm.com}
12
- s.extra_rdoc_files = ["README", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/mongomapper_patches.rb", "lib/grat/page.rb", "lib/grat/system.rb", "lib/grat/template.rb"]
13
- s.files = ["Manifest", "README", "Rakefile", "config.ru", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/mongomapper_patches.rb", "lib/grat/page.rb", "lib/grat/system.rb", "lib/grat/template.rb", "public/gratfiles/application.js", "public/gratfiles/custom.css", "public/gratfiles/einars-js-beautify/HTML-Beautify.js", "public/gratfiles/einars-js-beautify/beautify-cl.js", "public/gratfiles/einars-js-beautify/beautify-tests.js", "public/gratfiles/einars-js-beautify/beautify.js", "public/gratfiles/einars-js-beautify/bin/beautify_js", "public/gratfiles/einars-js-beautify/index.html", "public/gratfiles/einars-js-beautify/javascriptobfuscator_unpacker.js", "public/gratfiles/einars-js-beautify/license.txt", "public/gratfiles/einars-js-beautify/sanitytest.js", "public/gratfiles/einars-js-beautify/unmaintained/bbedit/jsBeautify_BBED.scpt", "public/gratfiles/einars-js-beautify/unmaintained/c-sharp/JSBeautify.cs", "public/gratfiles/einars-js-beautify/unmaintained/opera-userscript/make_opera_userscript.sh", "public/gratfiles/einars-js-beautify/unmaintained/opera-userscript/opera_userscript.js", "public/gratfiles/favicon.ico", "public/gratfiles/jquery-combined.min.js", "public/gratfiles/js-beautifier.min.js", "public/gratfiles/oocss.min.css", "public/gratfiles/oocss/content.css", "public/gratfiles/oocss/grids.css", "public/gratfiles/oocss/grids_debug.css", "public/gratfiles/oocss/libraries.css", "public/gratfiles/oocss/mod.css", "public/gratfiles/oocss/mod_debug.css", "public/gratfiles/oocss/mod_skins.css", "public/gratfiles/oocss/talk.css", "public/gratfiles/oocss/talk_skins.css", "public/gratfiles/oocss/template.css", "public/gratfiles/oocss/template_debug.css", "views/content_form.haml", "views/css/_content.sass", "views/css/_custom.sass", "views/css/_grids.sass", "views/css/_grids_debug.sass", "views/css/_libraries.sass", "views/css/_mod.sass", "views/css/_mod_debug.sass", "views/css/_mod_skins.sass", "views/css/_template.sass", "views/css/_template_debug.sass", "views/layout.haml", "views/list.haml", "views/missing.haml", "grat.gemspec"]
12
+ s.extra_rdoc_files = ["README", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/mongomapper_patches.rb", "lib/grat/system.rb"]
13
+ s.files = ["Manifest", "README", "Rakefile", "config.ru", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/mongomapper_patches.rb", "lib/grat/system.rb", "public/gratfiles/application.js", "public/gratfiles/custom.css", "public/gratfiles/einars-js-beautify/HTML-Beautify.js", "public/gratfiles/einars-js-beautify/beautify-cl.js", "public/gratfiles/einars-js-beautify/beautify-tests.js", "public/gratfiles/einars-js-beautify/beautify.js", "public/gratfiles/einars-js-beautify/bin/beautify_js", "public/gratfiles/einars-js-beautify/index.html", "public/gratfiles/einars-js-beautify/javascriptobfuscator_unpacker.js", "public/gratfiles/einars-js-beautify/license.txt", "public/gratfiles/einars-js-beautify/sanitytest.js", "public/gratfiles/einars-js-beautify/unmaintained/bbedit/jsBeautify_BBED.scpt", "public/gratfiles/einars-js-beautify/unmaintained/c-sharp/JSBeautify.cs", "public/gratfiles/einars-js-beautify/unmaintained/opera-userscript/make_opera_userscript.sh", "public/gratfiles/einars-js-beautify/unmaintained/opera-userscript/opera_userscript.js", "public/gratfiles/favicon.ico", "public/gratfiles/jquery-combined.min.js", "public/gratfiles/js-beautifier.min.js", "public/gratfiles/oocss.min.css", "public/gratfiles/oocss/content.css", "public/gratfiles/oocss/grids.css", "public/gratfiles/oocss/grids_debug.css", "public/gratfiles/oocss/libraries.css", "public/gratfiles/oocss/mod.css", "public/gratfiles/oocss/mod_debug.css", "public/gratfiles/oocss/mod_skins.css", "public/gratfiles/oocss/talk.css", "public/gratfiles/oocss/talk_skins.css", "public/gratfiles/oocss/template.css", "public/gratfiles/oocss/template_debug.css", "views/content_form.haml", "views/css/_content.sass", "views/css/_custom.sass", "views/css/_grids.sass", "views/css/_grids_debug.sass", "views/css/_libraries.sass", "views/css/_mod.sass", "views/css/_mod_debug.sass", "views/css/_mod_skins.sass", "views/css/_template.sass", "views/css/_template_debug.sass", "views/layout.haml", "views/list.haml", "views/missing.haml", "grat.gemspec"]
14
14
  s.homepage = %q{http://samsm.com/}
15
15
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Grat", "--main", "README"]
16
16
  s.require_paths = ["lib"]
data/lib/environment.rb CHANGED
@@ -36,8 +36,6 @@ module Grat
36
36
  MongoMapper.direct_database = database
37
37
 
38
38
  require Grat.lib_path + '/grat/content'
39
- require Grat.lib_path + '/grat/page'
40
- require Grat.lib_path + '/grat/template'
41
39
 
42
40
  end
43
41
  end
data/lib/grat/content.rb CHANGED
@@ -1,19 +1,18 @@
1
- module Grat::Content
2
-
3
- def self.included(base)
4
- base.key :url, String
5
- base.validates_uniqueness_of :url
6
- base.key :content, String
7
- base.key :tags, Array
8
- base.key :template_url, String
9
- base.key :variables_needed, Array
10
- base.timestamps!
11
-
12
- base.before_save :detect_default_content_vars
13
- base.key :default_content_vars, Hash
14
-
15
- base.key :render_engine_name, String
16
- end
1
+ class Grat::Content
2
+ include MongoMapper::Document
3
+
4
+ key :url, String
5
+ validates_uniqueness_of :url
6
+ key :content, String
7
+ key :tags, Array
8
+ key :template_url, String
9
+ key :variables_needed, Array
10
+ timestamps!
11
+
12
+ before_save :detect_default_content_vars
13
+ key :default_content_vars, Hash
14
+
15
+ key :render_engine_name, String
17
16
 
18
17
  def editable_fields
19
18
  attributes.reject {|k,v| uneditable_keys.include? k }
@@ -30,6 +29,10 @@ module Grat::Content
30
29
  super(val.kind_of?(Array) ? val : val.split(' '))
31
30
  end
32
31
 
32
+ def self.find_all_by_tag(tag_name)
33
+ all(:conditions => {'tags' => [tag_name]})
34
+ end
35
+
33
36
  def type
34
37
  self.class.to_s.sub(/.+::/, '')
35
38
  end
@@ -39,7 +42,7 @@ module Grat::Content
39
42
  end
40
43
 
41
44
  def template
42
- @template ||= Grat::Template.find_by_url(template_url) if template_url
45
+ @template ||= Grat::Content.find_by_url(template_url) if template_url
43
46
  end
44
47
 
45
48
  def template=(var)
@@ -67,26 +70,7 @@ module Grat::Content
67
70
  raise 'Unimplemented!'
68
71
  end
69
72
  end
70
-
71
- # def detect_variables_needed_by_content
72
- # demo_variables = {}
73
- # # formats = [String,Array] # later
74
- # render_fails = true
75
- # counter = 0
76
- # while render_fails
77
- # counter += 1
78
- # return false if counter > 200 # no infinite loop, thanks
79
- # begin
80
- # content_with(demo_variables)
81
- # render_fails = false
82
- # rescue
83
- # var = $!.to_s.sub(/.+`/,'').sub(/'.+/,'')
84
- # demo_variables[var] = 'text'
85
- # end
86
- # end
87
- # self.variables_needed = demo_variables.keys
88
- # end
89
-
73
+
90
74
  def detect_default_content_vars
91
75
  counter = 0
92
76
  while problem_var = detect_problem_var
data/lib/grat/system.rb CHANGED
@@ -28,13 +28,7 @@ module Grat::System
28
28
  # This avoids requiring mongomapper when it isn't needed
29
29
  Grat.database_load
30
30
 
31
- @model =
32
- case url.split('/')[1]
33
- when 'templates'
34
- Grat::Template
35
- else
36
- Grat::Page
37
- end
31
+ @model = Grat::Content
38
32
  end
39
33
 
40
34
  def focus_params
data/lib/grat.rb CHANGED
@@ -19,8 +19,8 @@ class Grat::Application < Sinatra::Base
19
19
  end
20
20
 
21
21
  get '/admin/__all' do
22
- @pages = Page.all
23
- @templates = Template.all
22
+ @pages = model.all
23
+ @templates = templates
24
24
  haml :list
25
25
  end
26
26
 
@@ -48,6 +48,10 @@ class Grat::Application < Sinatra::Base
48
48
  require 'haml'
49
49
  super(*args)
50
50
  end
51
+
52
+ def templates
53
+ model.find_all_by_tag('template')
54
+ end
51
55
 
52
56
  helpers do
53
57
  def form_nest(name)
@@ -1,22 +1,22 @@
1
1
  .grat_greet
2
2
  - if content.new_record?
3
3
  %p
4
- Let's make a
4
+ Let's make some
5
5
  %strong= url
6
- ==#{content.type}!
6
+ content!
7
7
  - else
8
8
  %p
9
9
  Editing
10
10
  %a{:href => url}
11
11
  %strong= url
12
- == (a #{content.type})
12
+ content.
13
13
 
14
14
  %form{:action => "/admin#{url}", :method => 'post'}
15
15
  .template
16
16
  %label{:for => form_nest('template_url')} Template
17
17
  %select{:name => form_nest('template_url')}
18
18
  %option{:value=>''} None
19
- - Grat::Template.all.each do |template|
19
+ - templates.each do |template|
20
20
  - option_hash = {:value => template.url}
21
21
  - option_hash.merge!(:selected => 'selected') if template.url == content.template_url
22
22
  %option{option_hash}= template.url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Schenkman-Moore
@@ -52,7 +52,7 @@ dependencies:
52
52
  - !ruby/object:Gem::Version
53
53
  version: "0"
54
54
  version:
55
- description: Minimal CMS for Rack and MongoDB.
55
+ description: Basic interface for making webpages with Haml and (later) erb. Supports nested templates.
56
56
  email: samsm@samsm.com
57
57
  executables: []
58
58
 
@@ -64,9 +64,7 @@ extra_rdoc_files:
64
64
  - lib/grat.rb
65
65
  - lib/grat/content.rb
66
66
  - lib/grat/mongomapper_patches.rb
67
- - lib/grat/page.rb
68
67
  - lib/grat/system.rb
69
- - lib/grat/template.rb
70
68
  files:
71
69
  - Manifest
72
70
  - README
@@ -76,9 +74,7 @@ files:
76
74
  - lib/grat.rb
77
75
  - lib/grat/content.rb
78
76
  - lib/grat/mongomapper_patches.rb
79
- - lib/grat/page.rb
80
77
  - lib/grat/system.rb
81
- - lib/grat/template.rb
82
78
  - public/gratfiles/application.js
83
79
  - public/gratfiles/custom.css
84
80
  - public/gratfiles/einars-js-beautify/HTML-Beautify.js
data/lib/grat/page.rb DELETED
@@ -1,5 +0,0 @@
1
- class Grat::Page
2
- include MongoMapper::Document
3
- include Grat::Content
4
-
5
- end
data/lib/grat/template.rb DELETED
@@ -1,13 +0,0 @@
1
- class Grat::Template
2
- include MongoMapper::Document
3
- include Grat::Content
4
-
5
- BEGINS_WITH_TEMPLATE = /\A\/templates\/.+/
6
-
7
- validates_format_of :url, :with => BEGINS_WITH_TEMPLATE, :message => "needs to begin with '/templates'"
8
-
9
- def url=(val)
10
- super(val =~ BEGINS_WITH_TEMPLATE ? val : '/templates/' + val.sub(/\A\//,''))
11
- end
12
-
13
- end