merbiful-release 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ The person or persons who have associated work with this document (the "Dedicator" or "Certifier") hereby either (a) certifies that, to the best of his knowledge, the work of authorship identified is in the public domain of the country from which the work is published, or (b) hereby dedicates whatever copyright the dedicators holds in the work of authorship identified below (the "Work") to the public domain. A certifier, moreover, dedicates any copyright interest he may have in the associated work, and for these purposes, is described as a "dedicator" below.
2
+
3
+ A certifier has taken reasonable steps to verify the copyright status of this work. Certifier recognizes that his good faith efforts may not shield him from liability if in fact the work certified is not in the public domain.
4
+
5
+ Dedicator makes this dedication for the benefit of the public at large and to the detriment of the Dedicator's heirs and successors. Dedicator intends this dedication to be an overt act of relinquishment in perpetuity of all present and future rights under copyright law, whether vested or contingent, in the Work. Dedicator understands that such relinquishment of all rights includes the relinquishment of all rights to enforce (by lawsuit or otherwise) those copyrights in the Work.
6
+
7
+ Dedicator recognizes that, once placed in the public domain, the Work may be freely reproduced, distributed, transmitted, used, modified, built upon, or otherwise exploited by anyone for any purpose, commercial or non-commercial, and in any way, including by methods that have not yet been invented or conceived.
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'pathname'
5
5
 
6
6
  PLUGIN = "merbiful-release"
7
7
  NAME = "merbiful-release"
8
- GEM_VERSION = "0.0.3"
8
+ GEM_VERSION = "0.1.0"
9
9
  AUTHOR = "Martin Kihlgren"
10
10
  EMAIL = "martin@wemind.se"
11
11
  HOMEPAGE = ""
@@ -25,7 +25,7 @@ spec = Gem::Specification.new do |s|
25
25
  s.add_dependency('dm-core', '>= 0.9.5')
26
26
  s.require_path = 'lib'
27
27
  s.autorequire = PLUGIN
28
- s.files = %w(Rakefile) + Dir.glob("{lib,specs,templates}/**/*")
28
+ s.files = %w(Rakefile LICENSE) + Dir.glob("{lib,specs,templates}/**/*")
29
29
  end
30
30
 
31
31
  Rake::GemPackageTask.new(spec) do |pkg|
@@ -199,6 +199,10 @@ module Merbiful
199
199
 
200
200
  private
201
201
 
202
+ def confirm(message)
203
+ "return confirm('#{message}');"
204
+ end
205
+
202
206
  def text_area_rows
203
207
  20
204
208
  end
@@ -249,7 +253,7 @@ module Merbiful
249
253
  rval << "</a>"
250
254
  rval << "<li class='up'><a href='#{url(:merbiful_admin, :action => 'move_page_up', :page_id => page.id)}'>&uarr;</a></li>"
251
255
  rval << "<li class='down'><a href='#{url(:merbiful_admin, :action => 'move_page_down', :page_id => page.id)}'>&darr;</a></li>"
252
- rval << "<li class='remove'><a href='#{url(:merbiful_admin, :action => 'destroy_page', :page_id => page.id)}'>-</a></li>" unless page.parent_id.nil?
256
+ rval << "<li class='remove'><a href='#{url(:merbiful_admin, :action => 'destroy_page', :page_id => page.id)}' onclick=\"#{confirm("Are you absolutely certain that you want to destroy the page at #{page.path}? All versions will be irreversibly destroyed.")}\">-</a></li>" unless page.parent_id.nil?
253
257
  rval << "<li class='append'><a href='#{url(:merbiful_admin, :action => 'create_page', :parent_id => page.id)}'>+</a></li>"
254
258
  rval << "</ul>"
255
259
  rval << render_template_without_layout("page_form.html.haml") if params[:page_id].to_s == page.id.to_s
@@ -122,17 +122,13 @@ module Merbiful
122
122
 
123
123
  def destroy_page
124
124
  page = Page.get(params[:page_id])
125
- page.versions.each do |version|
126
- version.css_nesses.destroy!
127
- version.js_nesses.destroy!
128
- version.destroy
129
- end
130
125
  page.destroy
131
126
  redirect url(:merbiful_admin, :action => "pages")
132
127
  end
133
128
 
134
129
  def upload_image
135
130
  path = Pathname.new(File.join(Merb.root, "public", "images", File.basename(params[:image][:filename])))
131
+ raise "H4xx0r" unless path.to_s.index(Pathname.new(Merb.root).expand_path.to_s) == 0
136
132
  Pathname.new(params[:image][:tempfile].path).rename(path)
137
133
  redirect url(:merbiful_admin, :action => "images")
138
134
  end
@@ -146,27 +142,18 @@ module Merbiful
146
142
 
147
143
  def destroy_layout
148
144
  layout = Layout.get(params[:layout_id])
149
- layout.page_versions.each do |page_version|
150
- page_version.layout = nil
151
- page_version.save
152
- end
153
- layout.layout_versions.destroy!
154
145
  layout.destroy
155
146
  redirect url(:merbiful_admin, :action => "layouts")
156
147
  end
157
148
 
158
149
  def destroy_css
159
150
  css = Css.get(params[:css_id])
160
- css.css_nesses.destroy!
161
- css.css_versions.destroy!
162
151
  css.destroy
163
152
  redirect url(:merbiful_admin, :action => "css")
164
153
  end
165
154
 
166
155
  def destroy_js
167
156
  js = Js.get(params[:js_id])
168
- js.js_nesses.destroy!
169
- js.js_versions.destroy!
170
157
  js.destroy
171
158
  redirect url(:merbiful_admin, :action => "js")
172
159
  end
@@ -181,19 +168,19 @@ module Merbiful
181
168
  def create_css
182
169
  new_css = Css.create(:name => next_name(Css))
183
170
  new_css_version = Css::Version.create(:css => new_css)
184
- redirect url(:merbiful_admin, :action => 'css')
171
+ redirect url(:merbiful_admin, :action => 'css', :css_id => new_css.id)
185
172
  end
186
173
 
187
174
  def create_js
188
175
  new_js = Js.create(:name => next_name(Js))
189
176
  new_js_version = Js::Version.create(:js => new_js)
190
- redirect url(:merbiful_admin, :action => 'js')
177
+ redirect url(:merbiful_admin, :action => 'js', :js_id => new_js.id)
191
178
  end
192
179
 
193
180
  def create_layout
194
181
  new_layout = Layout.create(:name => next_name(Layout))
195
182
  new_layout_version = Layout::Version.create(:layout => new_layout)
196
- redirect url(:merbiful_admin, :action => 'layouts')
183
+ redirect url(:merbiful_admin, :action => 'layouts', :layout_id => new_layout.id)
197
184
  end
198
185
 
199
186
  def move_page_up
@@ -6,7 +6,7 @@
6
6
  %a{:href => url(:merbiful_admin, :action => "css", :css_id => css.id)}
7
7
  %li{:class => "css_name"}= css.name
8
8
  %li{:class => "css_version"}= "ver##{css.latest.id} (#{time_ago_in_words(css.latest.created_at)} ago)"
9
- %li= link_to("-", url(:merbiful_admin, :action => "destroy_css", :css_id => css.id))
9
+ %li= link_to("-", url(:merbiful_admin, :action => "destroy_css", :css_id => css.id), :onclick => confirm("Are you absolutely certain that you want to destroy the css named #{css.name}? All versions will be irreversibly destroyed."))
10
10
  - if params[:css_id].to_s == css.id.to_s
11
11
  %table.css
12
12
  %form{:action => url(:merbiful_admin, :action => "css", :css_id => css.id), :method => "post"}
@@ -10,20 +10,23 @@
10
10
  - if params[:css_id].to_s == css.id.to_s
11
11
  %table.css
12
12
  %form{:action => url(:merbiful_admin, :action => "css", :css_id => css.id), :method => "post"}
13
+ %tr{:class => "version"}
14
+ %td Viewing version
15
+ %td= @form_css.css_versions(:order => [:id.desc]).collect do |v| "<a class='#{v.id == @form_version.id ? 'active' : 'inactive'}' href='#{url(:merbiful_admin, :action => "css", :css_id => @form_css.id, :version_id => v.id)}'>#{v.id}</a>" end.join(", ")
13
16
  %tr
14
- %td Name
17
+ %td Name (not versioned)
15
18
  %td= text_field(:name => "css[name]", :value => @form_css.name) + errors(@form_css, :name)
16
19
  %tr
17
20
  %td Body
18
- %td~ text_area(@form_css.body, :name => "version[body]", :cols => 80, :rows => text_area_rows) + errors(@form_version, :body)
21
+ %td~ text_area(@form_version.body, :name => "version[body]", :cols => 80, :rows => text_area_rows) + errors(@form_version, :body)
19
22
  %tr{:class => "filter"}
20
23
  %td Filter
21
- %td= select(:name => "version[filter]", :collection => Merbiful::filters, :selected => @form_css.latest.filter) + errors(@form_version, :filter)
24
+ %td= select(:name => "version[filter]", :collection => Merbiful::Filter.filters, :selected => @form_version.filter) + errors(@form_version, :filter)
22
25
  %tr
23
- %td Media
26
+ %td Media (not versioned)
24
27
  %td= text_field(:name => "css[media]", :value => @form_css.media) + errors(@form_css, :media)
25
28
  %tr{:class => "cached"}
26
- %td Cached
29
+ %td Cached (not versioned)
27
30
  %td= check_box(:name => "css[cached]", :checked => @form_css.cached) + errors(@form_css, :cached)
28
31
  %tr{:class => "submit"}
29
- %td{:colspan => "2"}= submit("Save")
32
+ %td{:colspan => "2"}= submit("Save as new version")
@@ -6,7 +6,7 @@
6
6
  %a{:href => url(:merbiful_admin, :action => "js", :js_id => js.id)}
7
7
  %li{:class => "js_name"}= js.name
8
8
  %li{:class => "js_version"}= "ver##{js.latest.id} (#{time_ago_in_words(js.latest.created_at)} ago)"
9
- %li= link_to("-", url(:merbiful_admin, :action => "destroy_js", :js_id => js.id))
9
+ %li= link_to("-", url(:merbiful_admin, :action => "destroy_js", :js_id => js.id), :onclick => confirm("Are you absolutely certain that you want to destroy the js named #{js.name}? All versions will be irreversibly destroyed."))
10
10
  - if params[:js_id].to_s == js.id.to_s
11
11
  %table.js
12
12
  %form{:action => url(:merbiful_admin, :action => "js", :js_id => js.id), :method => "post"}
@@ -0,0 +1,29 @@
1
+ %a{:href => url(:merbiful_admin, :action => "create_js")} New js
2
+ %ul{:class => "js"}
3
+ - Merbiful::Js.all.each do |js|
4
+ %li{:class => "js"}
5
+ %ul{:class => "js_info info"}
6
+ %a{:href => url(:merbiful_admin, :action => "js", :js_id => js.id)}
7
+ %li{:class => "js_name"}= js.name
8
+ %li{:class => "js_version"}= "ver##{js.latest.id} (#{time_ago_in_words(js.latest.created_at)} ago)"
9
+ %li= link_to("-", url(:merbiful_admin, :action => "destroy_js", :js_id => js.id))
10
+ - if params[:js_id].to_s == js.id.to_s
11
+ %table.js
12
+ %form{:action => url(:merbiful_admin, :action => "js", :js_id => js.id), :method => "post"}
13
+ %tr{:class => "version"}
14
+ %td Viewing version
15
+ %td= @form_js.js_versions(:order => [:id.desc]).collect do |v| "<a class='#{v.id == @form_version.id ? 'active' : 'inactive'}' href='#{url(:merbiful_admin, :action => "js", :js_id => @form_js.id, :version_id => v.id)}'>#{v.id}</a>" end.join(", ")
16
+ %tr
17
+ %td Name (not versioned)
18
+ %td= text_field(:name => "js[name]", :value => @form_js.name) + errors(@form_js, :name)
19
+ %tr
20
+ %td Body
21
+ %td~ text_area(@form_version.body, :name => "version[body]", :cols => 80, :rows => text_area_rows) + errors(@form_version, :body)
22
+ %tr{:class => "filter"}
23
+ %td Filter
24
+ %td= select(:name => "version[filter]", :collection => Merbiful::Filter.filters, :selected => @form_version.filter) + errors(@form_version, :filter)
25
+ %tr{:class => "cached"}
26
+ %td Cached (not versioned)
27
+ %td= check_box(:name => "js[cached]", :checked => @form_js.cached) + errors(@form_js, :cached)
28
+ %tr{:class => "submit"}
29
+ %td{:colspan => "2"}= submit("Save as new version")
@@ -6,7 +6,7 @@
6
6
  %a{:href => url(:merbiful_admin, :action => "layouts", :layout_id => layout.id)}
7
7
  %li{:class => "layout_name"}= layout.name
8
8
  %li{:class => "layout_version"}= "ver##{layout.latest.id} (#{time_ago_in_words(layout.latest.created_at)} ago)"
9
- %li= link_to("-", url(:merbiful_admin, :action => "destroy_layout", :layout_id => layout.id))
9
+ %li= link_to("-", url(:merbiful_admin, :action => "destroy_layout", :layout_id => layout.id), :onclick => confirm("Are you absolutely certain that you want to destroy the layout named #{layout.name}? All versions will be irreversibly destroyed."))
10
10
  - if params[:layout_id].to_s == layout.id.to_s
11
11
  %table.layout
12
12
  %form{:action => url(:merbiful_admin, :action => "layouts", :layout_id => layout.id), :method => "post"}
@@ -23,4 +23,4 @@
23
23
  %td Filter
24
24
  %td= select(:name => "version[filter]", :collection => Merbiful::Filter.filters, :selected => @form_version.filter) + errors(@form_version, :filter)
25
25
  %tr{:class => "submit"}
26
- %td{:colspan => "2"}= submit("Save as new version")
26
+ %td{:colspan => "2"}= submit("Save as new version")
@@ -0,0 +1,26 @@
1
+ %a{:href => url(:merbiful_admin, :action => "create_layout")} New layout
2
+ %ul{:class => "layouts"}
3
+ - Merbiful::Layout.all.each do |layout|
4
+ %li{:class => "layout"}
5
+ %ul{:class => "layout_info info"}
6
+ %a{:href => url(:merbiful_admin, :action => "layouts", :layout_id => layout.id)}
7
+ %li{:class => "layout_name"}= layout.name
8
+ %li{:class => "layout_version"}= "ver##{layout.latest.id} (#{time_ago_in_words(layout.latest.created_at)} ago)"
9
+ %li= link_to("-", url(:merbiful_admin, :action => "destroy_layout", :layout_id => layout.id))
10
+ - if params[:layout_id].to_s == layout.id.to_s
11
+ %table.layout
12
+ %form{:action => url(:merbiful_admin, :action => "layouts", :layout_id => layout.id), :method => "post"}
13
+ %tr{:class => "version"}
14
+ %td Viewing version
15
+ %td= @form_layout.layout_versions(:order => [:id.desc]).collect do |v| "<a class='#{v.id == @form_version.id ? 'active' : 'inactive'}' href='#{url(:merbiful_admin, :action => "layouts", :layout_id => @form_layout.id, :version_id => v.id)}'>#{v.id}</a>" end.join(", ")
16
+ %tr
17
+ %td Name (not versioned)
18
+ %td= text_field(:name => "layout[name]", :value => @form_layout.name) + errors(@form_layout, :name)
19
+ %tr
20
+ %td Body
21
+ %td~ text_area(@form_version.body, :name => "version[body]", :cols => 80, :rows => text_area_rows) + errors(@form_version, :body)
22
+ %tr{:class => "filter"}
23
+ %td Filter
24
+ %td= select(:name => "version[filter]", :collection => Merbiful::Filter.filters, :selected => @form_version.filter) + errors(@form_version, :filter)
25
+ %tr{:class => "submit"}
26
+ %td{:colspan => "2"}= submit("Save as new version")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merbiful-release
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martin Kihlgren
@@ -42,6 +42,7 @@ extra_rdoc_files: []
42
42
 
43
43
  files:
44
44
  - Rakefile
45
+ - LICENSE
45
46
  - lib/merbiful-release
46
47
  - lib/merbiful-release/admin.rb
47
48
  - lib/merbiful-release/admin.rb~
@@ -79,7 +80,9 @@ files:
79
80
  - templates/images.html.haml~
80
81
  - templates/index.html.haml
81
82
  - templates/js.html.haml
83
+ - templates/js.html.haml~
82
84
  - templates/layouts.html.haml
85
+ - templates/layouts.html.haml~
83
86
  - templates/page_form.html.haml
84
87
  - templates/page_form.html.haml~
85
88
  has_rdoc: true