grat 0.0.6.2 → 0.0.7
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 +1 -0
- data/README +14 -5
- data/Rakefile +1 -1
- data/grat.gemspec +3 -3
- data/lib/grat.rb +36 -9
- data/views/content_form.haml +3 -3
- data/views/delete.haml +14 -0
- data/views/import_form.haml +1 -1
- data/views/list.haml +2 -2
- data/views/missing.haml +5 -5
- metadata +3 -2
data/Manifest
CHANGED
data/README
CHANGED
@@ -20,8 +20,17 @@ Use it like so:
|
|
20
20
|
run Grat::Application
|
21
21
|
4. rackup (or passenger, if you know how)
|
22
22
|
|
23
|
-
5. http://localhost:9292/
|
24
|
-
6. http://localhost:9292/
|
25
|
-
7. http://localhost:9292/
|
26
|
-
8. http://localhost:9292/
|
27
|
-
|
23
|
+
5. http://localhost:9292/__admin/edit/mypage edits a page that will be available at http://localhost:9292/mypage
|
24
|
+
6. http://localhost:9292/__admin/all for a list of all pages
|
25
|
+
7. http://localhost:9292/__admin/export to get a json dump of all pages
|
26
|
+
8. http://localhost:9292/__admin/import to import one of those dumps
|
27
|
+
|
28
|
+
9. Protect from writes by strangers with Rack::If
|
29
|
+
http://github.com/samsm/Rackif
|
30
|
+
|
31
|
+
use Rack::If, :method => /(POST)|(PUT)|(DELETE)/ do
|
32
|
+
use Rack::Auth::Basic, "Grat protected" do |username, password|
|
33
|
+
'secret' == password
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
3
3
|
require 'rake'
|
4
4
|
require 'echoe'
|
5
5
|
|
6
|
-
Echoe.new('grat', '0.0.
|
6
|
+
Echoe.new('grat', '0.0.7') do |p|
|
7
7
|
p.summary = "Minimal CMS for Rack and MongoDB."
|
8
8
|
p.description = "Basic interface for making webpages with Haml and Erb. Supports nested templates."
|
9
9
|
p.url = "http://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.
|
5
|
+
s.version = "0.0.7"
|
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
|
-
s.date = %q{2009-11-
|
9
|
+
s.date = %q{2009-11-13}
|
10
10
|
s.description = %q{Basic interface for making webpages with Haml and Erb. Supports nested templates.}
|
11
11
|
s.email = %q{samsm@samsm.com}
|
12
12
|
s.extra_rdoc_files = ["README", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/hash_binding.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/hash_binding.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/import_form.haml", "views/layout.haml", "views/list.haml", "views/missing.haml", "grat.gemspec"]
|
13
|
+
s.files = ["Manifest", "README", "Rakefile", "config.ru", "lib/environment.rb", "lib/grat.rb", "lib/grat/content.rb", "lib/grat/hash_binding.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/delete.haml", "views/import_form.haml", "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/grat.rb
CHANGED
@@ -5,6 +5,7 @@ class Grat::Application < Sinatra::Base
|
|
5
5
|
include Grat::System
|
6
6
|
|
7
7
|
set :views, Grat.view_path
|
8
|
+
set :methodoverride, true
|
8
9
|
|
9
10
|
# serve some static assets directly from gem
|
10
11
|
get '/gratfiles/:filename' do
|
@@ -18,27 +19,27 @@ class Grat::Application < Sinatra::Base
|
|
18
19
|
file_data
|
19
20
|
end
|
20
21
|
|
21
|
-
get '/
|
22
|
+
get '/__admin/all' do
|
22
23
|
@pages = model.all
|
23
24
|
@templates = templates
|
24
25
|
haml :list
|
25
26
|
end
|
26
27
|
|
27
|
-
get '/
|
28
|
+
get '/__admin/export' do
|
28
29
|
content_type('text/json')
|
29
30
|
# Content-disposition: attachment; filename=fname.ext
|
30
31
|
response['Content-disposition'] = "attachment; filename=grat-#{request.host}-export-at-#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.json"
|
31
32
|
model.all.to_json
|
32
33
|
end
|
33
34
|
|
34
|
-
get '/
|
35
|
+
get '/__admin/import' do
|
35
36
|
haml :import_form
|
36
37
|
end
|
37
38
|
|
38
|
-
post '/
|
39
|
+
post '/__admin/import' do
|
39
40
|
json_text = file_import_text || params[:import][:text]
|
40
41
|
@import_results = import(json_text, params[:import][:strategy])
|
41
|
-
redirect '/
|
42
|
+
redirect '/__admin/all'
|
42
43
|
end
|
43
44
|
|
44
45
|
# Rather inefficient at present.
|
@@ -75,13 +76,27 @@ class Grat::Application < Sinatra::Base
|
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
78
|
-
get '/
|
79
|
+
get '/__admin/edit/*' do
|
79
80
|
haml :content_form
|
80
81
|
end
|
81
82
|
|
82
|
-
|
83
|
+
get '/__admin/delete/*' do
|
84
|
+
haml :delete
|
85
|
+
end
|
86
|
+
|
87
|
+
put '/*' do
|
88
|
+
content.update_attributes(focus_params)
|
89
|
+
redirect edit_path(content.url)
|
90
|
+
end
|
91
|
+
|
92
|
+
delete '/*' do
|
93
|
+
content.destroy
|
94
|
+
redirect edit_path(content.url)
|
95
|
+
end
|
96
|
+
|
97
|
+
post '/*' do
|
83
98
|
content.update_attributes(focus_params)
|
84
|
-
redirect
|
99
|
+
redirect edit_path(content.url)
|
85
100
|
end
|
86
101
|
|
87
102
|
get '/*' do
|
@@ -95,10 +110,22 @@ class Grat::Application < Sinatra::Base
|
|
95
110
|
end
|
96
111
|
end
|
97
112
|
|
113
|
+
not_found do
|
114
|
+
haml :missing
|
115
|
+
end
|
116
|
+
|
117
|
+
def edit_path(url)
|
118
|
+
"/__admin/edit#{url}"
|
119
|
+
end
|
120
|
+
|
121
|
+
def delete_path(url)
|
122
|
+
"/__admin/delete#{url}"
|
123
|
+
end
|
124
|
+
|
98
125
|
def combine_docs(text,template,vars)
|
99
126
|
template.content_with(vars,text)
|
100
127
|
end
|
101
|
-
|
128
|
+
|
102
129
|
def haml(*args)
|
103
130
|
require 'haml'
|
104
131
|
super(*args)
|
data/views/content_form.haml
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
.grat_greet
|
2
2
|
- if content.new_record?
|
3
|
-
%p
|
3
|
+
%p
|
4
4
|
Let's make some
|
5
5
|
%strong= url
|
6
6
|
content!
|
7
7
|
- else
|
8
8
|
%p
|
9
|
-
Editing
|
9
|
+
Editing
|
10
10
|
%a{:href => url}
|
11
11
|
%strong= url
|
12
12
|
content.
|
13
13
|
|
14
|
-
%form{:action => "
|
14
|
+
%form{:action => "#{content.url}", :method => 'post'}
|
15
15
|
.template
|
16
16
|
%label{:for => form_nest('template_url')} Template
|
17
17
|
%select{:name => form_nest('template_url')}
|
data/views/delete.haml
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
.grat_greet
|
2
|
+
- if content.new_record?
|
3
|
+
%p
|
4
|
+
What? There's no record here to delete.
|
5
|
+
- else
|
6
|
+
%p
|
7
|
+
Sure you want to delete
|
8
|
+
%a{:href => url}
|
9
|
+
%strong= url
|
10
|
+
content.
|
11
|
+
|
12
|
+
%form{:action => "#{url}", :method => 'post'}
|
13
|
+
%input{:type => 'hidden', :name => '_method', :value => 'delete'}
|
14
|
+
%input{:type => 'submit', :name => 'submit', :value => "Delete"}
|
data/views/import_form.haml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
.grat_greet
|
2
2
|
%p Hey, import some json if you like.
|
3
|
-
%form{:action => "/
|
3
|
+
%form{:action => "/__admin/import", :method => 'post', :enctype=>'multipart/form-data' }
|
4
4
|
.import_file
|
5
5
|
%label{:for => 'import_file'} Upload a json file:
|
6
6
|
%input{:id => 'import_file', :type => 'file', :name => 'import[file]'}
|
data/views/list.haml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
%li
|
7
7
|
%a{:href => page.url}= page.url
|
8
8
|
(
|
9
|
-
%a{:href =>
|
9
|
+
%a{:href => edit_path(page.url)} edit
|
10
10
|
)
|
11
11
|
%h2 Templates
|
12
12
|
%ol
|
@@ -14,5 +14,5 @@
|
|
14
14
|
%li
|
15
15
|
%a{:href => template.url}= template.url
|
16
16
|
(
|
17
|
-
%a{:href =>
|
17
|
+
%a{:href => edit_path(template.url)} edit
|
18
18
|
)
|
data/views/missing.haml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
%h1 Wut?
|
2
|
-
%p
|
3
|
-
Are you from the future? Yes?
|
2
|
+
%p
|
3
|
+
Are you from the future? Yes?
|
4
4
|
Ok, well you
|
5
5
|
%i should
|
6
6
|
know this from your research of our time, but FYI: that page doesn't exist yet.
|
7
|
-
%p
|
8
|
-
Maybe you'd like to
|
9
|
-
%a{:href=>
|
7
|
+
%p
|
8
|
+
Maybe you'd like to
|
9
|
+
%a{:href=> edit_path(url)} create it
|
10
10
|
\.
|
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.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Schenkman-Moore
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-13 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- views/css/_mod_skins.sass
|
119
119
|
- views/css/_template.sass
|
120
120
|
- views/css/_template_debug.sass
|
121
|
+
- views/delete.haml
|
121
122
|
- views/import_form.haml
|
122
123
|
- views/layout.haml
|
123
124
|
- views/list.haml
|