manuscript 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -7,5 +7,9 @@ module Manuscript
7
7
  has_attached_file :file,
8
8
  :path => "./template_files/:id/:basename.:extension",
9
9
  :url => "/template_files/:id/:basename.:extension"
10
+
11
+ def url
12
+ file.url
13
+ end
10
14
  end
11
15
  end
@@ -19,8 +19,29 @@ module Manuscript
19
19
  @file = TemplateFile.new
20
20
  @file.file = new_file
21
21
  @file.save
22
- puts @file.inspect
23
- puts params.inspect
22
+ redirect '/admin/template_files'
23
+ end
24
+
25
+ get '/admin/template_files/:id/edit' do
26
+ @file = TemplateFile.find(params[:id])
27
+ haml :edit_template_file
28
+ end
29
+
30
+ put '/admin/template_files/:id' do
31
+ new_file = params[:template_file][:file][:tempfile]
32
+ new_file.original_filename = params[:template_file][:file][:filename]
33
+
34
+ @file = TemplateFile.find(params[:id])
35
+ raise Sinatra::NotFound unless @file
36
+ @file.file = new_file
37
+ @file.save
38
+ redirect '/admin/template_files'
39
+ end
40
+
41
+ delete '/admin/template_files/:id' do
42
+ @file = TemplateFile.find(params[:id])
43
+ raise Sinatra::NotFound unless @file
44
+ @file.destroy
24
45
  redirect '/admin/template_files'
25
46
  end
26
47
  end
data/manuscript.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{manuscript}
8
- s.version = "0.1.5"
8
+ s.version = "0.1.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["hotink"]
@@ -52,6 +52,7 @@ Gem::Specification.new do |s|
52
52
  "spec/manuscript/template_manager_spec.rb",
53
53
  "spec/spec.opts",
54
54
  "spec/spec_helper.rb",
55
+ "views/edit_template_file.haml",
55
56
  "views/layout.haml",
56
57
  "views/menu.haml",
57
58
  "views/new_template_file.haml",
@@ -0,0 +1,9 @@
1
+ %p
2
+ %a{ :href => "/admin/template_files" } &laquo back
3
+ %form{:method =>:post, :action => "/admin/template_files/#{@file.id}", :enctype => "multipart/form-data"}
4
+ %fieldset
5
+ %legend
6
+ = "Replace file: #{@file.url}"
7
+ %input{:type => 'file', :name => 'template_file[file]', :id => 'template_file_file'}
8
+ %input{:type => 'hidden', :name => '_method', :value => 'put'}
9
+ %input{ :type => :submit, :value => "Upload" }
@@ -1,7 +1,7 @@
1
1
  %p
2
2
  %a{ :href => "/admin/template_files" } &laquo back
3
3
  %form{:method =>:post, :action => "/admin/template_files", :enctype => "multipart/form-data"}
4
- %label
5
- Upload template file
4
+ %fieldset
5
+ %legend Upload template file
6
6
  %input{:type => 'file', :name => 'template_file[file]', :id => 'template_file_file'}
7
- %input{ :type => :submit }
7
+ %input{ :type => :submit, :value => "Upload" }
@@ -2,5 +2,8 @@
2
2
  %ol
3
3
  - @files.each do |file|
4
4
  %li
5
- = file.file.url
5
+ = "#{file.url} "
6
+ %small
7
+ %a{:href => "/admin/template_files/#{file.id}/edit"} edit
8
+ %a{ :onclick => "if(confirm('You are about to delete a template file. Click OK to delete or Cancel to return to the page.')) { var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); { f.method = 'POST'; f.action = this.href;var m = document.createElement('input'); m.setAttribute('type', 'hidden'); m.setAttribute('name', '_method'); m.setAttribute('value', 'delete'); f.appendChild(m);f.submit(); } } return false;", :href => "/admin/template_files/#{file.id}" } delete
6
9
  %a{ :href => "/admin/template_files/new" } Upload a file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manuscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - hotink
@@ -137,6 +137,7 @@ files:
137
137
  - spec/manuscript/template_manager_spec.rb
138
138
  - spec/spec.opts
139
139
  - spec/spec_helper.rb
140
+ - views/edit_template_file.haml
140
141
  - views/layout.haml
141
142
  - views/menu.haml
142
143
  - views/new_template_file.haml