sushifish 0.0.1 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/generators/USAGE +8 -0
- data/lib/generators/sushi/sushi_generator.rb +117 -0
- data/lib/generators/sushi/templates/_admin_nav.html.haml +3 -0
- data/lib/generators/sushi/templates/_footer.html.haml +1 -0
- data/lib/generators/sushi/templates/_form.html.erb +75 -0
- data/lib/generators/sushi/templates/_header.html.haml +1 -0
- data/lib/generators/sushi/templates/_navigation.html.haml +12 -0
- data/lib/generators/sushi/templates/_page.html.haml +9 -0
- data/lib/generators/sushi/templates/_sidebar.html.haml +0 -0
- data/lib/generators/sushi/templates/admin.sass +284 -0
- data/lib/generators/sushi/templates/admin_pages_controller.rb +46 -0
- data/lib/generators/sushi/templates/application.html.haml +22 -0
- data/lib/generators/sushi/templates/application_controller.rb +15 -0
- data/lib/generators/sushi/templates/dashboard_controller.rb +7 -0
- data/lib/generators/sushi/templates/edit.html.erb +5 -0
- data/lib/generators/sushi/templates/edit.html.haml +7 -0
- data/lib/generators/sushi/templates/index.html.haml +1 -0
- data/lib/generators/sushi/templates/indexes_and_defaults.rb +11 -0
- data/lib/generators/sushi/templates/layout.sass +17 -0
- data/lib/generators/sushi/templates/migrations/ancestry_migration.rb +11 -0
- data/lib/generators/sushi/templates/new.html.erb +5 -0
- data/lib/generators/sushi/templates/open.css.erb +1 -0
- data/lib/generators/sushi/templates/page.html.haml +27 -0
- data/lib/generators/sushi/templates/page.rb +60 -0
- data/lib/generators/sushi/templates/page_controller.rb +10 -0
- data/lib/generators/sushi/templates/page_helper.rb +31 -0
- data/lib/generators/sushi/templates/pages_index.html.haml +26 -0
- data/lib/generators/sushi/templates/reset.sass +21 -0
- data/lib/generators/sushi/templates/show.html.erb +20 -0
- data/lib/generators/sushi/templates/show.html.haml +9 -0
- data/lib/generators/sushi/templates/style.css.scss +3 -0
- data/lib/generators/sushi/templates/style.sass +56 -0
- data/lib/generators/sushi/templates/stylesheets_controller.rb +27 -0
- data/lib/generators/sushi/templates/superfish.sass +81 -0
- data/lib/sushifish/version.rb +1 -1
- data/sushifish.gemspec +2 -2
- metadata +39 -5
@@ -0,0 +1,117 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class SushiGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
argument :app_name, :type => :string, :default => "website"
|
8
|
+
|
9
|
+
# http://stackoverflow.com/questions/6199301/global-access-to-rake-dsl-methods-is-deprecated
|
10
|
+
# https://github.com/rails/rails/commit/83f257fc4862642af29056cb5b7dfef6e1303754
|
11
|
+
# Fixed in Rails 3.1?
|
12
|
+
# def rake_dsl_fix
|
13
|
+
# gsub_file "Rakefile", "require File.expand_path('../config/application', __FILE__)", "require File.expand_path('../config/application', __FILE__)\nrequire 'rake/dsl_definition'"
|
14
|
+
#
|
15
|
+
# gsub_file "Rakefile", "require 'rake'", "require 'rake'\ninclude Rake::DSL"
|
16
|
+
# end
|
17
|
+
|
18
|
+
def create_models
|
19
|
+
generate :model, 'page name:string content:text page_title:string meta_keywords:text meta_description:text sidebar_html:text ancestry:string short_nav:string order_by:integer show_in_nav:boolean'
|
20
|
+
generate :model, 'stylesheet body:text'
|
21
|
+
rake 'db:migrate'
|
22
|
+
remove_file '/app/models/page.rb'
|
23
|
+
copy_file 'page.rb', 'app/models/page.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def indexes_and_defaults
|
27
|
+
migration_template 'indexes_and_defaults.rb', 'db/migrate/indexes_and_defaults.rb'
|
28
|
+
rake 'db:migrate'
|
29
|
+
end
|
30
|
+
|
31
|
+
def remove_files
|
32
|
+
remove_file 'public/index.html' if File.exists?('public/index.html')
|
33
|
+
remove_file 'app/views/layouts/application.html.erb' if File.exists?('app/views/layouts/application.html.erb')
|
34
|
+
remove_file 'public/images/rails.png' if File.exists?('public/images/rails.png')
|
35
|
+
end
|
36
|
+
|
37
|
+
def add_routes
|
38
|
+
route "root :to => 'page#show#index', :page => 'index'"
|
39
|
+
route "match ':section(/:page)' => 'page#show#:page', :as => :link"
|
40
|
+
route "resources :pages, :module => 'admin'"
|
41
|
+
route "resources :messages, :module => 'admin'"
|
42
|
+
route "resource :stylesheet"
|
43
|
+
route "get 'stylesheets/open'"
|
44
|
+
end
|
45
|
+
|
46
|
+
def copy_files
|
47
|
+
copy_file 'admin_pages_controller.rb', 'app/controllers/admin/pages_controller.rb'
|
48
|
+
copy_file 'application_controller.rb', 'app/controllers/application_controller.rb'
|
49
|
+
copy_file 'dashboard_controller.rb', 'app/controllers/dashboard_controller.rb'
|
50
|
+
copy_file 'stylesheets_controller.rb', 'app/controllers/stylesheets_controller.rb'
|
51
|
+
copy_file 'page_controller.rb', 'app/controllers/page_controller.rb'
|
52
|
+
copy_file 'page_helper.rb', 'app/helpers/page_helper.rb'
|
53
|
+
copy_file 'index.html.haml', 'app/views/page/index.html.haml'
|
54
|
+
copy_file 'page.html.haml', 'app/views/layouts/page.html.haml'
|
55
|
+
template 'application.html.haml', 'app/views/layouts/application.html.haml'
|
56
|
+
# copy_file 'style.sass', 'public/stylesheets/sass/style.sass'
|
57
|
+
# copy_file 'reset.sass', 'public/stylesheets/sass/reset.sass'
|
58
|
+
# copy_file 'admin.sass', 'public/stylesheets/sass/admin.sass'
|
59
|
+
# copy_file 'layout.sass', 'public/stylesheets/sass/layout.sass'
|
60
|
+
# copy_file 'superfish.sass', 'public/stylesheets/sass/superfish.sass'
|
61
|
+
copy_file 'style.css.scss', 'app/assets/stylesheets/style.css.scss'
|
62
|
+
copy_file 'show.html.haml', 'app/views/page/show.html.haml'
|
63
|
+
copy_file '_header.html.haml', 'app/views/page/_header.html.haml'
|
64
|
+
copy_file '_navigation.html.haml', 'app/views/page/_navigation.html.haml'
|
65
|
+
copy_file '_sidebar.html.haml', 'app/views/page/_sidebar.html.haml'
|
66
|
+
copy_file '_footer.html.haml', 'app/views/page/_footer.html.haml'
|
67
|
+
copy_file 'edit.html.erb', 'app/views/admin/pages/edit.html.erb'
|
68
|
+
copy_file 'edit.html.haml', 'app/views/stylesheets/edit.html.haml'
|
69
|
+
copy_file 'open.css.erb', 'app/views/stylesheets/open.css.erb'
|
70
|
+
copy_file 'pages_index.html.haml', 'app/views/admin/pages/index.html.haml'
|
71
|
+
copy_file 'new.html.erb', 'app/views/admin/pages/new.html.erb'
|
72
|
+
copy_file 'show.html.erb', 'app/views/admin/pages/show.html.erb'
|
73
|
+
copy_file '_admin_nav.html.haml', 'app/views/layouts/_admin_nav.html.haml'
|
74
|
+
copy_file '_form.html.erb', 'app/views/admin/pages/_form.html.erb'
|
75
|
+
end
|
76
|
+
|
77
|
+
def git_some
|
78
|
+
run 'git init'
|
79
|
+
run 'git add .'
|
80
|
+
run "gc -m 'inital commit'"
|
81
|
+
end
|
82
|
+
|
83
|
+
# def gems
|
84
|
+
# gem 'haml', '2.2.24'
|
85
|
+
# gem 'jquery-rails'
|
86
|
+
# gem 'ancestry'
|
87
|
+
#
|
88
|
+
# gsub_file "Gemfile", /#.*\n/, "\n"
|
89
|
+
# gsub_file "Gemfile", /\n+/, "\n"
|
90
|
+
#
|
91
|
+
# run 'bundle'
|
92
|
+
# end
|
93
|
+
|
94
|
+
# def jquery_setup
|
95
|
+
# generate 'jquery:install --ui'
|
96
|
+
# end
|
97
|
+
|
98
|
+
def seed_data
|
99
|
+
append_file 'db/seeds.rb', "Stylesheet.create! :body => '/* inject style here. */'\n"
|
100
|
+
append_file 'db/seeds.rb', "Page.create! :name => 'index', :content => 'i am index. i have no data.'"
|
101
|
+
rake 'db:seed'
|
102
|
+
end
|
103
|
+
|
104
|
+
def blast_off
|
105
|
+
run 'touch tmp/restart.txt'
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
def self.next_migration_number(dirname)
|
111
|
+
if ActiveRecord::Base.timestamped_migrations
|
112
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
113
|
+
else
|
114
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
footer
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<%= form_for(@page) do |f| %>
|
2
|
+
<fieldset class="inputs">
|
3
|
+
<% if @page.errors.any? %>
|
4
|
+
<div id="error_explanation">
|
5
|
+
<h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
|
6
|
+
|
7
|
+
<ul>
|
8
|
+
<% @page.errors.full_messages.each do |msg| %>
|
9
|
+
<li><%= msg %></li>
|
10
|
+
<% end %>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<ol class="main">
|
16
|
+
|
17
|
+
<li class="string required title">
|
18
|
+
<%= f.label :Location %><br />
|
19
|
+
<%= f.collection_select :parent_id, Page.all(:order => "name"), :id, :name, :include_blank => true %> /
|
20
|
+
<%= f.text_field :name %>
|
21
|
+
</li>
|
22
|
+
<li class="title">
|
23
|
+
<ul class="check_boxes">
|
24
|
+
<li class="field">
|
25
|
+
<%= f.label "Show in navigation?" %>
|
26
|
+
<%= f.check_box :show_in_nav %>
|
27
|
+
<p class="inline-hints">check box for item to appear in navigation</p>
|
28
|
+
</li>
|
29
|
+
</ul>
|
30
|
+
</li>
|
31
|
+
<li class="string required title">
|
32
|
+
<%= f.label :short_nav %><br />
|
33
|
+
<%= f.text_field :short_nav %>
|
34
|
+
</li>
|
35
|
+
<li class="string required title">
|
36
|
+
<%= f.label :order %><br />
|
37
|
+
<%= f.text_field :order_by %>
|
38
|
+
<p class="inline-hints">this will appear in title</p>
|
39
|
+
</li>
|
40
|
+
|
41
|
+
<li class="string required title">
|
42
|
+
<%= f.label :title %><br />
|
43
|
+
<%= f.text_field :page_title %>
|
44
|
+
<p class="inline-hints">this will appear in title</p>
|
45
|
+
</li>
|
46
|
+
<li class="string required title">
|
47
|
+
<%= f.label :meta_keywords %><br />
|
48
|
+
<%= f.text_area :meta_keywords, :class => 'small' %>
|
49
|
+
</li>
|
50
|
+
<li class="string required title">
|
51
|
+
<%= f.label :meta_description %><br />
|
52
|
+
<%= f.text_area :meta_description, :class => 'small' %>
|
53
|
+
</li>
|
54
|
+
<li class="string required title">
|
55
|
+
<%= f.label :content %><br />
|
56
|
+
<%= f.text_area :content %>
|
57
|
+
</li>
|
58
|
+
<li class="string required title">
|
59
|
+
</li>
|
60
|
+
<hr>
|
61
|
+
<li class="buttons">
|
62
|
+
<%= f.submit %>
|
63
|
+
</li>
|
64
|
+
</ol>
|
65
|
+
<div class="sidebar">
|
66
|
+
<ol>
|
67
|
+
<li class="select required">
|
68
|
+
<%= f.label :sidebar %><br />
|
69
|
+
<%= f.text_area :sidebar_html %>
|
70
|
+
</li>
|
71
|
+
</ol>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
</fieldset>
|
75
|
+
<% end %>
|
@@ -0,0 +1 @@
|
|
1
|
+
#logo
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%ul{ :class => "sf-menu" }
|
2
|
+
- Page.navigation.each do |root|
|
3
|
+
%li
|
4
|
+
= link_to root.link, link_path(root.name)
|
5
|
+
%ul
|
6
|
+
- root.children.show_in_nav.each do |item|
|
7
|
+
%li
|
8
|
+
= nav_link(item)
|
9
|
+
- unless item.children.empty?
|
10
|
+
%ul
|
11
|
+
- item.children.each do |item|
|
12
|
+
%li= nav_link(item)
|
File without changes
|
@@ -0,0 +1,284 @@
|
|
1
|
+
html
|
2
|
+
color: #222
|
3
|
+
font-size: 13px
|
4
|
+
font-family: "Helvetica Neue", "Lucida Grande", Helvetica, Arial, Verdana, sans-serif
|
5
|
+
body
|
6
|
+
background-color: #ccc
|
7
|
+
#container
|
8
|
+
width: 1024px
|
9
|
+
margin: 0 auto
|
10
|
+
padding: 0
|
11
|
+
#header
|
12
|
+
background-color: #09275e
|
13
|
+
color: #fff
|
14
|
+
padding: 10px 25px
|
15
|
+
height: 20px
|
16
|
+
.user_nav
|
17
|
+
float: right
|
18
|
+
font-size: 15px
|
19
|
+
#navigation
|
20
|
+
background-color: #666
|
21
|
+
padding: 0 0 0 10px
|
22
|
+
margin: 0
|
23
|
+
height: 30px
|
24
|
+
font-size: 110%
|
25
|
+
ul
|
26
|
+
margin: 0 0 0 0px
|
27
|
+
li
|
28
|
+
padding: 6px 0
|
29
|
+
float: left
|
30
|
+
margin: 0 15px 0 0
|
31
|
+
a, a:visited
|
32
|
+
color: #fff
|
33
|
+
text-decoration: none
|
34
|
+
padding: 7px 15px
|
35
|
+
a:hover
|
36
|
+
background: #999
|
37
|
+
color: #333
|
38
|
+
padding: 7px 15px
|
39
|
+
#flash
|
40
|
+
background-color: #000000
|
41
|
+
#content
|
42
|
+
background-color: #fff
|
43
|
+
padding: 10px 20px 25px 20px
|
44
|
+
margin: 0
|
45
|
+
a, a:visited
|
46
|
+
color: #09275e
|
47
|
+
text-decoration: none
|
48
|
+
font-weight: bold
|
49
|
+
ol.main
|
50
|
+
float: left
|
51
|
+
width: 620px
|
52
|
+
ul
|
53
|
+
li
|
54
|
+
line-height: 17px
|
55
|
+
letter-spacing: .2px
|
56
|
+
.sidebar
|
57
|
+
border-left: 1px solid #c8c8c8
|
58
|
+
width: 290px
|
59
|
+
margin: 0 0 0 10px
|
60
|
+
padding: 0 0 0 10px
|
61
|
+
float: right
|
62
|
+
#footer
|
63
|
+
background-color: #09275e
|
64
|
+
color: #fff
|
65
|
+
padding: 10px 20px
|
66
|
+
|
67
|
+
h1
|
68
|
+
font-size: 140%
|
69
|
+
margin: 15px 0
|
70
|
+
|
71
|
+
|
72
|
+
table
|
73
|
+
margin-bottom: 2em
|
74
|
+
width: 100%
|
75
|
+
|
76
|
+
th
|
77
|
+
border-bottom: 2px solid #ccc
|
78
|
+
font-weight: bold
|
79
|
+
text-align: left
|
80
|
+
|
81
|
+
td
|
82
|
+
border-bottom: 1px solid #ddd
|
83
|
+
|
84
|
+
caption, th, td
|
85
|
+
padding: 4px 10px 4px 0
|
86
|
+
|
87
|
+
caption
|
88
|
+
background: #f1f1f1
|
89
|
+
padding: 10px 0
|
90
|
+
margin-bottom: 1em
|
91
|
+
|
92
|
+
tr, td, th
|
93
|
+
vertical-align: middle
|
94
|
+
|
95
|
+
|
96
|
+
/* Forms
|
97
|
+
|
98
|
+
input[type="submit"]::-moz-focus-inner
|
99
|
+
border: none
|
100
|
+
|
101
|
+
/*removes dotted outline on submit buttons when clicking in firefox
|
102
|
+
|
103
|
+
form ol.main
|
104
|
+
list-style: none
|
105
|
+
margin: 0 0 1em 0
|
106
|
+
ol
|
107
|
+
margin-left: 0
|
108
|
+
li
|
109
|
+
margin: 0 0 1em 0
|
110
|
+
list-style-position: outside
|
111
|
+
ol li
|
112
|
+
margin: 0 0 .25em 0
|
113
|
+
list-style-position: outside
|
114
|
+
li.error input
|
115
|
+
background: #FBE3E4
|
116
|
+
|
117
|
+
form ol
|
118
|
+
list-style: none
|
119
|
+
margin: 0 0 1em 0
|
120
|
+
ol
|
121
|
+
margin-left: 0
|
122
|
+
li
|
123
|
+
margin: 0 0 1em 0
|
124
|
+
list-style-position: outside
|
125
|
+
ol li
|
126
|
+
margin: 0 0 .25em 0
|
127
|
+
list-style-position: outside
|
128
|
+
li.error input
|
129
|
+
background: #FBE3E4
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
/*list-style-position fixes IE label margin bug
|
134
|
+
|
135
|
+
p.inline-errors
|
136
|
+
color: #D12F19
|
137
|
+
|
138
|
+
form
|
139
|
+
ol li.file
|
140
|
+
background: #e1e1e1
|
141
|
+
border: 1px solid #c8c8c8
|
142
|
+
padding: 10px
|
143
|
+
abbr
|
144
|
+
border-bottom: 0
|
145
|
+
|
146
|
+
label
|
147
|
+
display: block
|
148
|
+
|
149
|
+
.required label
|
150
|
+
font-weight: bold
|
151
|
+
|
152
|
+
.checkbox_field label, .radio_field label
|
153
|
+
font-weight: normal
|
154
|
+
|
155
|
+
a.cancel
|
156
|
+
color: #7d0d0d
|
157
|
+
|
158
|
+
.inline-hints
|
159
|
+
font-size: 0.8em
|
160
|
+
color: #666
|
161
|
+
margin-bottom: 0.25em
|
162
|
+
|
163
|
+
/* Fieldsets
|
164
|
+
|
165
|
+
fieldset
|
166
|
+
margin: 0 0 1.5em 0
|
167
|
+
background: #f1f1f1
|
168
|
+
padding: 1.5em 1.5em 1em 1.5em
|
169
|
+
border: 1px solid #e3e3e3
|
170
|
+
fieldset
|
171
|
+
padding: 0
|
172
|
+
border: 0
|
173
|
+
fieldset
|
174
|
+
padding: 0
|
175
|
+
border: 0
|
176
|
+
|
177
|
+
legend
|
178
|
+
font-weight: bold
|
179
|
+
|
180
|
+
fieldset.buttons
|
181
|
+
background: inherit
|
182
|
+
border: 0
|
183
|
+
padding: 0
|
184
|
+
li
|
185
|
+
display: inline
|
186
|
+
|
187
|
+
.radio fieldset
|
188
|
+
padding: 0
|
189
|
+
margin: 0
|
190
|
+
|
191
|
+
/* Text fields
|
192
|
+
|
193
|
+
input
|
194
|
+
&[type="text"], &[type="password"]
|
195
|
+
width: 300px
|
196
|
+
padding: 3px 2px
|
197
|
+
font-size: inherit
|
198
|
+
&[disabled='disabled']
|
199
|
+
background-color: #fcfcfc
|
200
|
+
cursor: default
|
201
|
+
&[type="checkbox"], &[type="radio"]
|
202
|
+
margin: 0 3px 0 0
|
203
|
+
vertical-align: middle
|
204
|
+
position: relative
|
205
|
+
top: -2px
|
206
|
+
|
207
|
+
.check_boxes
|
208
|
+
label
|
209
|
+
vertical-align: middle
|
210
|
+
padding: 0
|
211
|
+
display: inline
|
212
|
+
font-weight: bold
|
213
|
+
margin: 0
|
214
|
+
padding: 0
|
215
|
+
li
|
216
|
+
list-style: none
|
217
|
+
|
218
|
+
.check
|
219
|
+
input
|
220
|
+
vertical-align: top
|
221
|
+
|
222
|
+
|
223
|
+
.radio label
|
224
|
+
padding: 0
|
225
|
+
|
226
|
+
/* Textareas
|
227
|
+
|
228
|
+
textarea
|
229
|
+
width: 90%
|
230
|
+
height: 200px
|
231
|
+
margin: 0 0.5em 0.5em 0
|
232
|
+
padding: 5px
|
233
|
+
font-size: inherit
|
234
|
+
|
235
|
+
textarea.wide
|
236
|
+
width: 840px
|
237
|
+
height: 200px
|
238
|
+
margin: 0 0.5em 0.5em 0
|
239
|
+
padding: 5px
|
240
|
+
font-size: inherit
|
241
|
+
|
242
|
+
textarea.stylesheet
|
243
|
+
width: 100%
|
244
|
+
height: 450px
|
245
|
+
margin: 0 0.5em 0.5em 0
|
246
|
+
padding: 5px
|
247
|
+
font-size: 120%
|
248
|
+
|
249
|
+
|
250
|
+
/* Select fields
|
251
|
+
|
252
|
+
fieldset .select select
|
253
|
+
width: 200px
|
254
|
+
font-size: 0.9em
|
255
|
+
|
256
|
+
optgroup
|
257
|
+
margin: 0 0 .5em 0
|
258
|
+
|
259
|
+
/* Date & Time
|
260
|
+
|
261
|
+
form ol li
|
262
|
+
&.date ol li, &.time ol li
|
263
|
+
display: inline
|
264
|
+
&.datetime
|
265
|
+
ol li
|
266
|
+
display: inline-block
|
267
|
+
select
|
268
|
+
display: inline
|
269
|
+
width: auto
|
270
|
+
&.date select, &.time select
|
271
|
+
display: inline
|
272
|
+
width: auto
|
273
|
+
&.date label, &.time label
|
274
|
+
display: none
|
275
|
+
|
276
|
+
#flash
|
277
|
+
margin: 0px 0 10px 0
|
278
|
+
width: 620px
|
279
|
+
color: #0f0f0f
|
280
|
+
font-size: 16px
|
281
|
+
.alert, .notice
|
282
|
+
background-color: #f5df94
|
283
|
+
border: solid 5px #f5d671
|
284
|
+
padding: 7px
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class Admin::PagesController < ApplicationController
|
2
|
+
before_filter :authenticate
|
3
|
+
|
4
|
+
def index
|
5
|
+
@pages = Page.order('updated_at desc')
|
6
|
+
end
|
7
|
+
|
8
|
+
def show
|
9
|
+
@page = Page.find(params[:id])
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@page = Page.new
|
14
|
+
end
|
15
|
+
|
16
|
+
def edit
|
17
|
+
@page = Page.find(params[:id])
|
18
|
+
end
|
19
|
+
|
20
|
+
def create
|
21
|
+
@page = Page.new(params[:page])
|
22
|
+
|
23
|
+
if @page.save
|
24
|
+
redirect_to(pages_path, :notice => 'Page was successfully created.')
|
25
|
+
else
|
26
|
+
render :action => "new"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
@page = Page.find(params[:id])
|
32
|
+
|
33
|
+
if @page.update_attributes(params[:page])
|
34
|
+
redirect_to(pages_path, :notice => 'Page was successfully updated.')
|
35
|
+
else
|
36
|
+
render :action => "edit"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
@page = Page.find(params[:id])
|
42
|
+
@page.destroy
|
43
|
+
|
44
|
+
redirect_to(pages_path, :notice => 'Page was successfully removed.')
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
!!! 5
|
2
|
+
|
3
|
+
%html
|
4
|
+
%head
|
5
|
+
%title <%= app_name %>
|
6
|
+
= stylesheet_link_tag 'reset','admin'
|
7
|
+
= javascript_include_tag :defaults
|
8
|
+
= csrf_meta_tag
|
9
|
+
|
10
|
+
%body{:id => "dashboard"}
|
11
|
+
#container
|
12
|
+
#header
|
13
|
+
<%= app_name %>
|
14
|
+
.user_nav
|
15
|
+
#navigation
|
16
|
+
= render :partial => "layouts/admin_nav"
|
17
|
+
#content
|
18
|
+
/ =render :partial => "layouts/flashes"
|
19
|
+
= yield
|
20
|
+
#footer
|
21
|
+
/ =render :partial => "layouts/footer"
|
22
|
+
/ =render :partial => "layouts/tracking"
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class ApplicationController < ActionController::Base
|
2
|
+
protect_from_forgery
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def authenticate
|
7
|
+
authenticate_or_request_with_http_basic do |username, password|
|
8
|
+
username == "admin" && password == "p4ss"
|
9
|
+
end
|
10
|
+
# Only needed if Devise is running
|
11
|
+
# warden.custom_failure! if performed?
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
i am index.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class IndexesAndDefaults < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
change_column_default :pages, :show_in_nav, true
|
4
|
+
add_index :pages, :ancestry
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.down
|
8
|
+
change_column_default :pages, :show_in_nav, nil
|
9
|
+
remove_index :pages, :ancestry
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
!minimum_height = 140px
|
2
|
+
html body
|
3
|
+
#container
|
4
|
+
margin: 0 auto
|
5
|
+
width: 980px
|
6
|
+
#header
|
7
|
+
#navigation
|
8
|
+
width: 100%
|
9
|
+
height: 35px
|
10
|
+
#flash
|
11
|
+
#content
|
12
|
+
min-height = !minimum_height
|
13
|
+
#sidebar
|
14
|
+
float: left
|
15
|
+
min-height = !minimum_height
|
16
|
+
#footer
|
17
|
+
clear: both
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= @style %>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
!!! 5
|
2
|
+
|
3
|
+
%html
|
4
|
+
%head
|
5
|
+
%title= yield(:title) || "Website"
|
6
|
+
%meta{:name => 'description', :content => "#{yield(:meta_desc)}"}
|
7
|
+
%meta{:name => "keywords", :content => "#{yield(:meta_keywords)}"}
|
8
|
+
|
9
|
+
= stylesheet_link_tag 'superfish', 'open'
|
10
|
+
= javascript_include_tag :defaults
|
11
|
+
= csrf_meta_tag
|
12
|
+
|
13
|
+
%body{:id => "#{yield(:page_name)}" || "default"}
|
14
|
+
|
15
|
+
#container
|
16
|
+
#header
|
17
|
+
= render 'header'
|
18
|
+
#navigation
|
19
|
+
= render 'navigation'
|
20
|
+
#content
|
21
|
+
= yield
|
22
|
+
#sidebar
|
23
|
+
= render 'sidebar'
|
24
|
+
#sidebar_html
|
25
|
+
#{yield(:sidebar)}
|
26
|
+
#footer
|
27
|
+
= render 'footer'
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Page < ActiveRecord::Base
|
2
|
+
validates_presence_of :name
|
3
|
+
validates_uniqueness_of :name
|
4
|
+
before_save :downcase_name
|
5
|
+
has_ancestry
|
6
|
+
|
7
|
+
def title
|
8
|
+
name.titleize
|
9
|
+
end
|
10
|
+
|
11
|
+
def search_result_title
|
12
|
+
r = page_title.split(' | ')
|
13
|
+
r[0]
|
14
|
+
end
|
15
|
+
|
16
|
+
def title
|
17
|
+
name.titleize
|
18
|
+
end
|
19
|
+
|
20
|
+
def link
|
21
|
+
short_nav.blank? ? title : short_nav
|
22
|
+
end
|
23
|
+
|
24
|
+
def nav_path
|
25
|
+
name
|
26
|
+
# if nominal
|
27
|
+
# if children.count > 0
|
28
|
+
# children.first.name
|
29
|
+
# else
|
30
|
+
# ""
|
31
|
+
# end
|
32
|
+
# else
|
33
|
+
# name
|
34
|
+
# end
|
35
|
+
end
|
36
|
+
|
37
|
+
scope :visible, where("visible = ?", true).order('id')
|
38
|
+
scope :home, where("page_type = ?", 'home')
|
39
|
+
scope :has_ancestors, where(:ancestry => nil)
|
40
|
+
scope :show_in_nav, where("show_in_nav = ?", true)
|
41
|
+
scope :sorted, order("order_by")
|
42
|
+
|
43
|
+
def self.navigation
|
44
|
+
has_ancestors.show_in_nav.sorted
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.search(search)
|
48
|
+
if search
|
49
|
+
find(:all, :conditions => ['name LIKE ? OR content LIKE ? OR page_title LIKE ? OR meta_keywords LIKE ? OR meta_description LIKE ?', "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%", "%#{search}%"])
|
50
|
+
else
|
51
|
+
find(:all)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
|
57
|
+
def downcase_name
|
58
|
+
self.name.downcase! unless self.name.blank?
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PageHelper
|
2
|
+
def title(page_title)
|
3
|
+
content_for(:title) { page_title.to_s + " | Application Name" }
|
4
|
+
end
|
5
|
+
|
6
|
+
def page_name(name)
|
7
|
+
content_for(:page_name) { name.to_s }
|
8
|
+
end
|
9
|
+
|
10
|
+
def meta_desc(desc)
|
11
|
+
content_for(:meta_desc) { desc.to_s }
|
12
|
+
end
|
13
|
+
|
14
|
+
def meta_keywords(desc)
|
15
|
+
content_for(:meta_keywords) { desc.to_s }
|
16
|
+
end
|
17
|
+
|
18
|
+
def sidebar(content)
|
19
|
+
content_for(:sidebar) { content.to_s }
|
20
|
+
end
|
21
|
+
|
22
|
+
def nav_link(page)
|
23
|
+
# link_to page.titleize, page_path(page.downcase), :id => page
|
24
|
+
if page.nav_path == ""
|
25
|
+
link_to page.link, '#'
|
26
|
+
else
|
27
|
+
link_to page.link, link_path(page.root.name, page.nav_path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
%h1 Listing pages
|
2
|
+
|
3
|
+
%table{:class => "tablesorter"}
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th{:width => 200} Name
|
7
|
+
%th{:width => 290} Content
|
8
|
+
/ %th{:width => 100} Type
|
9
|
+
/ %th{:width => 120} Visible
|
10
|
+
/ %th{:width => 170} Section
|
11
|
+
%th
|
12
|
+
%th
|
13
|
+
%tbody
|
14
|
+
- @pages.each do |page|
|
15
|
+
%tr
|
16
|
+
%td= page.name
|
17
|
+
%td= truncate page.content, :length => 60
|
18
|
+
/ %td= page.page_type
|
19
|
+
/ %td= page.visible
|
20
|
+
/ %td= page.section
|
21
|
+
/ %td= page.contactform
|
22
|
+
/ %td= page.accordion
|
23
|
+
%td= link_to 'Edit', edit_page_path(page)
|
24
|
+
%td= link_to 'Destroy', [page], :confirm => 'Are you sure?', :method => :delete
|
25
|
+
|
26
|
+
= link_to 'New Page', new_page_path
|
@@ -0,0 +1,21 @@
|
|
1
|
+
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td
|
2
|
+
margin: 0
|
3
|
+
padding: 0
|
4
|
+
font-size: 100%
|
5
|
+
vertical-align: baseline
|
6
|
+
border: 0
|
7
|
+
outline: 0
|
8
|
+
background: transparent
|
9
|
+
|
10
|
+
ol, ul
|
11
|
+
list-style: none
|
12
|
+
|
13
|
+
blockquote, q
|
14
|
+
quotes: none
|
15
|
+
|
16
|
+
\:focus
|
17
|
+
outline: 0
|
18
|
+
|
19
|
+
table
|
20
|
+
border-collapse: collapse
|
21
|
+
border-spacing: 0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
2
|
+
|
3
|
+
<p>
|
4
|
+
<b>Name:</b>
|
5
|
+
<%= @page.name %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<p>
|
9
|
+
<b>Content:</b>
|
10
|
+
<%= @page.content %>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<p>
|
14
|
+
<b>Visible:</b>
|
15
|
+
<%= @page.visible %>
|
16
|
+
</p>
|
17
|
+
|
18
|
+
|
19
|
+
<%= link_to 'Edit', edit_page_path(@page) %> |
|
20
|
+
<%= link_to 'Back', pages_path %>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
@import layout.sass
|
2
|
+
|
3
|
+
html
|
4
|
+
font: 13px/1.5em "Lucida Grande", calibri, Tahoma, Arial
|
5
|
+
body
|
6
|
+
#container
|
7
|
+
font-size: 1em
|
8
|
+
#header
|
9
|
+
color: #fff
|
10
|
+
#navigation
|
11
|
+
ul
|
12
|
+
float: left
|
13
|
+
#content
|
14
|
+
float: left
|
15
|
+
padding: 10px
|
16
|
+
h1, h2
|
17
|
+
margin: 10px 0 15px
|
18
|
+
p
|
19
|
+
margin: 10px 0 15px 0
|
20
|
+
#sidebar
|
21
|
+
color: #aaa
|
22
|
+
float: left
|
23
|
+
#footer
|
24
|
+
color: #aaa
|
25
|
+
clear: both
|
26
|
+
|
27
|
+
a,a:visited
|
28
|
+
color: #003399
|
29
|
+
text-decoration: none
|
30
|
+
|
31
|
+
h1, h2, h3, h4, h5, h6
|
32
|
+
font-family: helvetica, arial, verdana, sans-serif
|
33
|
+
font-weight: normal
|
34
|
+
|
35
|
+
h1
|
36
|
+
font-size: 208%
|
37
|
+
|
38
|
+
h2
|
39
|
+
font-size: 164%
|
40
|
+
|
41
|
+
h3
|
42
|
+
font-size: 145%
|
43
|
+
|
44
|
+
h4
|
45
|
+
font-size: 118%
|
46
|
+
|
47
|
+
|
48
|
+
// #flash
|
49
|
+
// margin: 10px 0
|
50
|
+
// width: 720px
|
51
|
+
// color: #0f0f0f
|
52
|
+
// font-size: 16px
|
53
|
+
// .alert, .notice
|
54
|
+
// background-color: #F5DF94
|
55
|
+
// border: solid 5px #F5D671
|
56
|
+
// padding: 7px
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class StylesheetsController < ApplicationController
|
2
|
+
def open
|
3
|
+
stylesheet = get_stylesheet
|
4
|
+
@style = stylesheet.body
|
5
|
+
end
|
6
|
+
|
7
|
+
def edit
|
8
|
+
@stylesheet = get_stylesheet
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
@stylesheet = get_stylesheet
|
13
|
+
|
14
|
+
if @stylesheet.update_attributes(params[:stylesheet])
|
15
|
+
redirect_to(edit_stylesheet_path, :notice => 'Stylesheet was successfully updated.')
|
16
|
+
else
|
17
|
+
render :action => "edit"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def get_stylesheet
|
25
|
+
Stylesheet.first
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/*** ESSENTIAL STYLES **
|
2
|
+
!ul_width = 16em
|
3
|
+
|
4
|
+
.sf-menu
|
5
|
+
margin: 0
|
6
|
+
padding: 0
|
7
|
+
list-style: none
|
8
|
+
*
|
9
|
+
margin: 0
|
10
|
+
padding: 0
|
11
|
+
list-style: none
|
12
|
+
line-height: 1em
|
13
|
+
ul
|
14
|
+
position: absolute
|
15
|
+
top: -999em
|
16
|
+
width: !ul_width
|
17
|
+
/* left offset of submenus need to match (see below)
|
18
|
+
li
|
19
|
+
width: 100%
|
20
|
+
li
|
21
|
+
&:hover
|
22
|
+
visibility: inherit
|
23
|
+
/* fixes IE7 'sticky bug'
|
24
|
+
float: left
|
25
|
+
position: relative
|
26
|
+
a
|
27
|
+
display: block
|
28
|
+
position: relative
|
29
|
+
li
|
30
|
+
&:hover ul, &.sfHover ul
|
31
|
+
left: 0
|
32
|
+
top: 2.7em
|
33
|
+
/* match top ul list item height
|
34
|
+
z-index: 99
|
35
|
+
|
36
|
+
ul.sf-menu li
|
37
|
+
&:hover li ul, &.sfHover li ul
|
38
|
+
top: -999em
|
39
|
+
li
|
40
|
+
&:hover ul, &.sfHover ul
|
41
|
+
left: !ul_width
|
42
|
+
/* match ul width
|
43
|
+
top: 0
|
44
|
+
&:hover li ul, &.sfHover li ul
|
45
|
+
top: -999em
|
46
|
+
li
|
47
|
+
&:hover ul, &.sfHover ul
|
48
|
+
left: !ul_width
|
49
|
+
/* match ul width
|
50
|
+
top: 0
|
51
|
+
|
52
|
+
/*** Styling **
|
53
|
+
|
54
|
+
.sf-menu
|
55
|
+
float: left
|
56
|
+
margin-bottom: 1em
|
57
|
+
a
|
58
|
+
padding: .4em .85em
|
59
|
+
text-decoration: none
|
60
|
+
/* visited pseudo selector so IE6 applies text colour
|
61
|
+
color: #fff
|
62
|
+
&:visited
|
63
|
+
/* visited pseudo selector so IE6 applies text colour
|
64
|
+
color: #fff
|
65
|
+
li
|
66
|
+
background: #000
|
67
|
+
padding: .4em 0
|
68
|
+
margin: 0
|
69
|
+
li
|
70
|
+
background: #000
|
71
|
+
padding: .4em 0
|
72
|
+
margin: 0
|
73
|
+
li
|
74
|
+
background: #000
|
75
|
+
&:hover, &.sfHover
|
76
|
+
background: #666
|
77
|
+
outline: 0
|
78
|
+
a
|
79
|
+
&:focus, &:hover, &:active
|
80
|
+
background: #666
|
81
|
+
outline: 0
|
data/lib/sushifish/version.rb
CHANGED
data/sushifish.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Travis"]
|
9
9
|
s.email = ["travis@impossiblecreature.com"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = %q{
|
12
|
-
s.description = %q{
|
11
|
+
s.summary = %q{The firt public version of the infamous Sushi Gem.}
|
12
|
+
s.description = %q{Sushi Fish is a generator that gives a raw rails app ready for content. It is a great starting point to a CMS driven site.}
|
13
13
|
|
14
14
|
s.rubyforge_project = "sushifish"
|
15
15
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sushifish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 9
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.1
|
10
|
+
version: 0.9.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Travis
|
@@ -19,7 +19,7 @@ date: 2012-02-06 00:00:00 -06:00
|
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
22
|
-
description:
|
22
|
+
description: Sushi Fish is a generator that gives a raw rails app ready for content. It is a great starting point to a CMS driven site.
|
23
23
|
email:
|
24
24
|
- travis@impossiblecreature.com
|
25
25
|
executables: []
|
@@ -32,6 +32,40 @@ files:
|
|
32
32
|
- .gitignore
|
33
33
|
- Gemfile
|
34
34
|
- Rakefile
|
35
|
+
- lib/generators/USAGE
|
36
|
+
- lib/generators/sushi/sushi_generator.rb
|
37
|
+
- lib/generators/sushi/templates/_admin_nav.html.haml
|
38
|
+
- lib/generators/sushi/templates/_footer.html.haml
|
39
|
+
- lib/generators/sushi/templates/_form.html.erb
|
40
|
+
- lib/generators/sushi/templates/_header.html.haml
|
41
|
+
- lib/generators/sushi/templates/_navigation.html.haml
|
42
|
+
- lib/generators/sushi/templates/_page.html.haml
|
43
|
+
- lib/generators/sushi/templates/_sidebar.html.haml
|
44
|
+
- lib/generators/sushi/templates/admin.sass
|
45
|
+
- lib/generators/sushi/templates/admin_pages_controller.rb
|
46
|
+
- lib/generators/sushi/templates/application.html.haml
|
47
|
+
- lib/generators/sushi/templates/application_controller.rb
|
48
|
+
- lib/generators/sushi/templates/dashboard_controller.rb
|
49
|
+
- lib/generators/sushi/templates/edit.html.erb
|
50
|
+
- lib/generators/sushi/templates/edit.html.haml
|
51
|
+
- lib/generators/sushi/templates/index.html.haml
|
52
|
+
- lib/generators/sushi/templates/indexes_and_defaults.rb
|
53
|
+
- lib/generators/sushi/templates/layout.sass
|
54
|
+
- lib/generators/sushi/templates/migrations/ancestry_migration.rb
|
55
|
+
- lib/generators/sushi/templates/new.html.erb
|
56
|
+
- lib/generators/sushi/templates/open.css.erb
|
57
|
+
- lib/generators/sushi/templates/page.html.haml
|
58
|
+
- lib/generators/sushi/templates/page.rb
|
59
|
+
- lib/generators/sushi/templates/page_controller.rb
|
60
|
+
- lib/generators/sushi/templates/page_helper.rb
|
61
|
+
- lib/generators/sushi/templates/pages_index.html.haml
|
62
|
+
- lib/generators/sushi/templates/reset.sass
|
63
|
+
- lib/generators/sushi/templates/show.html.erb
|
64
|
+
- lib/generators/sushi/templates/show.html.haml
|
65
|
+
- lib/generators/sushi/templates/style.css.scss
|
66
|
+
- lib/generators/sushi/templates/style.sass
|
67
|
+
- lib/generators/sushi/templates/stylesheets_controller.rb
|
68
|
+
- lib/generators/sushi/templates/superfish.sass
|
35
69
|
- lib/sushifish.rb
|
36
70
|
- lib/sushifish/version.rb
|
37
71
|
- sushifish.gemspec
|
@@ -68,6 +102,6 @@ rubyforge_project: sushifish
|
|
68
102
|
rubygems_version: 1.4.1
|
69
103
|
signing_key:
|
70
104
|
specification_version: 3
|
71
|
-
summary:
|
105
|
+
summary: The firt public version of the infamous Sushi Gem.
|
72
106
|
test_files: []
|
73
107
|
|