-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdemo.txt
109 lines (97 loc) · 2.99 KB
/
demo.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
gem 'papermill'
generate :papermill_table, "PapermillMigration"
generate :papermill_assets
generate :papermill_initializer
generate :scaffold, "article title:string"
rake "db:migrate"
file "app/models/article.rb", <<-END
class Article < ActiveRecord::Base
validates_presence_of :title
papermill :image_gallery, :thumbnail => {:width => 75, :height => 100}, :images_only => true # only images, custom preview thumbnail size
papermill :thumbnail, :swfupload => { :file_types => "*.jpg;*.jpeg" } # jpg only, cherry picking
papermill :my_assets
papermill :my_other_asset
end
END
file "app/views/articles/edit.html.erb", <<-END
<h1>Editing article</h1>
<%= render :partial => "form" %>
<%= link_to 'Show', @article %> |
<%= link_to 'Back', articles_path %>
END
file "app/views/articles/new.html.erb", <<-END
<h1>New article</h1>
<%= render :partial => "form" %>
<%= link_to 'Back', articles_path %>
END
file "app/views/articles/_form.html.erb", <<-END
<% form_for(@article) do |f| %>
<%= f.error_messages %><br /><br />
<%= f.label :title %><br />
<%= f.text_field :title %><br /><br />
<%= f.label :image_gallery %><br />
<%= f.images_upload(:image_gallery) %><br /><br />
<%= f.label :thumbnail %><br />
<%= f.image_upload(:thumbnail) %><br /><br />
<%= f.label :my_assets %><br />
<%= f.assets_upload(:my_assets) %><br /><br />
<%= f.label :my_other_asset %><br />
<%= f.asset_upload(:my_other_asset) %><br /><br />
<%= f.submit 'Send' %>
<% end %>
END
file "app/views/articles/show.html.erb", <<-END
<p>
<b>Title:</b>
<%=h @article.title %>
</p>
<br /><br />
<b>@article.image_gallery.each :</b>
<p>
<% @article.image_gallery.each do |image| %>
<%= link_to(image_tag(image.url("100x100#")), image.url) %>
<% end %>
</p>
<br /><br />
<b>@article.thumbnail.first :</b>
<p>
<% image = @article.thumbnail.first %>
<%= link_to(image_tag(image.url("100x100#")), image.url) if image %>
</p>
<br /><br />
<b>@article.my_assets.each :</b>
<p>
<ul>
<% @article.my_assets.each do |asset| %>
<li><%= link_to asset.name, asset.url %></li>
<% end %>
</ul>
</p>
<br /><br />
<b>@article.my_other_asset.first :</b>
<p>
<% asset = @article.my_other_asset.first %>
<%= link_to(asset.name, asset.url) if asset %>
</p>
<%= link_to 'Edit', edit_article_path(@article) %> |
<%= link_to 'Back', articles_path %>
END
file "app/views/layouts/application.html.erb", <<-END
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Papermill Demo</title>
<%= stylesheet_link_tag 'scaffold' %>
<%= papermill_stylesheet_tag %>
</head>
<body>
<%= yield %>
<%= papermill_javascript_tag :with_jquery => true %>
</body>
</html>
END
run "rm app/views/layouts/articles.html.erb"
run "rm public/index.html"
route "map.root :controller => 'articles'"