paginas 0.1.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +37 -0
- data/app/assets/javascripts/paginas.js +1 -0
- data/app/assets/javascripts/paginas/application.js +13 -0
- data/app/assets/javascripts/paginas/pages.js +2 -0
- data/app/assets/stylesheets/paginas/application.css +15 -0
- data/app/assets/stylesheets/paginas/pages.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/paginas/application_controller.rb +3 -0
- data/app/controllers/paginas/pages_controller.rb +61 -0
- data/app/helpers/paginas/application_helper.rb +11 -0
- data/app/helpers/paginas/pages_helper.rb +4 -0
- data/app/models/paginas/page.rb +5 -0
- data/app/views/paginas/pages/_form.html.erb +30 -0
- data/app/views/paginas/pages/display.html.erb +2 -0
- data/app/views/paginas/pages/edit.html.erb +6 -0
- data/app/views/paginas/pages/featured.html.erb +5 -0
- data/app/views/paginas/pages/index.html.erb +29 -0
- data/app/views/paginas/pages/new.html.erb +5 -0
- data/app/views/paginas/pages/show.html.erb +8 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20150212133316_create_paginas_pages.rb +11 -0
- data/lib/generators/paginas/view_generator.rb +91 -0
- data/lib/paginas.rb +4 -0
- data/lib/paginas/engine.rb +5 -0
- data/lib/paginas/version.rb +3 -0
- data/lib/tasks/paginas_tasks.rake +4 -0
- data/test/controllers/paginas/pages_controller_test.rb +51 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/schema.rb +24 -0
- data/test/dummy/log/development.log +674 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/005bd567a7d66421fbef453fe21291ef +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0af4c8229b96d670ece643ab86d847fc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0b561bb0f5e27b0811d8f78da0b0a961 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0d13d323f5ada0f6982ed7004e7b7956 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0d47ad626385700d816d2237b60e4405 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f9097e7e4fe024b14ad4ae2a74ac107 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2335821218ad3f7fb88a7e033bd928d3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2a6137c114f81313e7f4d24aabf5f742 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/31007be9c9b15ceb79a3575e593f1666 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/34c30def6edca7cd4ccc028324e69732 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3ccca1a97ac09ec192a60c94fa00adb3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/41485660f2da3e5246495eca44b5d586 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/43a987fa7ec0cbb1e8a6bd5e3a4e4b8d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4ccd723c93040294ae2c7d4bdd241927 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5549bda2a1379ba359a508ac6eef4fed +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/591767e1239aceceb8eae71f91d40c2c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5ca1d924e33e6d2326ea666473d1b957 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/614d6dfbd87dfef1f5409cdf648b4ef8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6870a0f5e39c9a385cd7d42d1eacc23a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6aff79b1163157bafd663772e01e02b9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ff1394e29e0bf6efa5e2aaaa5599857 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/79f273cae0828923dde1ef8c2398a097 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e4eb3e4ae47796be38b017098742457 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9245581aa4bb65f432f558fab76a6394 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a056f25be69aad65535c6119795b97a7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a0a7a60c30730860ddb157961fa79cc6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a4f760a14b35ee198d29bdc6657a6d61 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a9cc70badbab7d39abf8d96de550f53d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/abc2c4b52cfa5dec5d6d5f5bac7f7d7f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bac590af4a9c32bd96a7954f161597fd +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cb0b8f15d2f703e80dad62daa69e27b1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cd7fd8f917317ac993444f56a0dd0259 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d05c052069448c7d8dce96727613e470 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ec454ae07815a55a5b9bb5d5eb9de78b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f0089f75e018e7d19b6fe81ab885cd8e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/fixtures/paginas/pages.yml +11 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/models/paginas/page_test.rb +9 -0
- data/test/paginas_test.rb +7 -0
- data/test/test_helper.rb +19 -0
- metadata +286 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6a3e8012d96b794ee26499e6496a528146d2d280
|
|
4
|
+
data.tar.gz: 2229a347014befaa6bd6e1a18b573e0f93e42d3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5ed3a867faae3de2ed6ce244b57f7a6fba59d363bfa8c81cd3eb2c19957fa623eafb3286187472eb25c6a9ca212f2231feb5c7f14fdc1c55858ca6978cce8c83
|
|
7
|
+
data.tar.gz: c635dd498fdae739859d11d3bc133255c2469751e47598443b285d7ae7e7eec0b24f966cbeeb30a75aab5636795f81064e42319bdd6a24eef0ec993ddc8dd128
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2015 Carlos Roque
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'Paginas'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
load 'rails/tasks/statistics.rake'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Bundler::GemHelper.install_tasks
|
|
26
|
+
|
|
27
|
+
require 'rake/testtask'
|
|
28
|
+
|
|
29
|
+
Rake::TestTask.new(:test) do |t|
|
|
30
|
+
t.libs << 'lib'
|
|
31
|
+
t.libs << 'test'
|
|
32
|
+
t.pattern = 'test/**/*_test.rb'
|
|
33
|
+
t.verbose = false
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
task default: :test
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//= require tinymce
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
body { background-color: #fff; color: #333; }
|
|
2
|
+
|
|
3
|
+
body, p, ol, ul, td {
|
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
|
5
|
+
font-size: 13px;
|
|
6
|
+
line-height: 18px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
pre {
|
|
10
|
+
background-color: #eee;
|
|
11
|
+
padding: 10px;
|
|
12
|
+
font-size: 11px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
a { color: #000; }
|
|
16
|
+
a:visited { color: #666; }
|
|
17
|
+
a:hover { color: #fff; background-color:#000; }
|
|
18
|
+
|
|
19
|
+
div.field, div.actions {
|
|
20
|
+
margin-bottom: 10px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#notice {
|
|
24
|
+
color: green;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.field_with_errors {
|
|
28
|
+
padding: 2px;
|
|
29
|
+
background-color: red;
|
|
30
|
+
display: table;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
#error_explanation {
|
|
34
|
+
width: 450px;
|
|
35
|
+
border: 2px solid red;
|
|
36
|
+
padding: 7px;
|
|
37
|
+
padding-bottom: 0;
|
|
38
|
+
margin-bottom: 20px;
|
|
39
|
+
background-color: #f0f0f0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
#error_explanation h2 {
|
|
43
|
+
text-align: left;
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
padding: 5px 5px 5px 15px;
|
|
46
|
+
font-size: 12px;
|
|
47
|
+
margin: -7px;
|
|
48
|
+
margin-bottom: 0px;
|
|
49
|
+
background-color: #c00;
|
|
50
|
+
color: #fff;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
#error_explanation ul li {
|
|
54
|
+
font-size: 12px;
|
|
55
|
+
list-style: square;
|
|
56
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require_dependency "paginas/application_controller"
|
|
2
|
+
|
|
3
|
+
module Paginas
|
|
4
|
+
class PagesController < ApplicationController
|
|
5
|
+
before_action :set_page, only: [:show, :edit, :update, :destroy]
|
|
6
|
+
|
|
7
|
+
def index
|
|
8
|
+
if params[:featured]
|
|
9
|
+
@pages = Page.where(featured: true)
|
|
10
|
+
render :featured
|
|
11
|
+
else
|
|
12
|
+
@pages = Page.all
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def show
|
|
17
|
+
if params[:display_only]
|
|
18
|
+
render :display
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def new
|
|
23
|
+
@page = Page.new
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def edit
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create
|
|
30
|
+
@page = Page.new(page_params)
|
|
31
|
+
|
|
32
|
+
if @page.save
|
|
33
|
+
redirect_to @page, notice: 'Page was successfully created.'
|
|
34
|
+
else
|
|
35
|
+
render :new
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def update
|
|
40
|
+
if @page.update(page_params)
|
|
41
|
+
redirect_to @page, notice: 'Page was successfully updated.'
|
|
42
|
+
else
|
|
43
|
+
render :edit
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def destroy
|
|
48
|
+
@page.destroy
|
|
49
|
+
redirect_to pages_url, notice: 'Page was successfully destroyed.'
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
def set_page
|
|
54
|
+
@page = Page.find(params[:id])
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def page_params
|
|
58
|
+
params.require(:page).permit(:title, :text, :featured)
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module Paginas
|
|
2
|
+
module ApplicationHelper
|
|
3
|
+
def method_missing(method, *args, &block)
|
|
4
|
+
if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)
|
|
5
|
+
main_app.send(method, *args)
|
|
6
|
+
else
|
|
7
|
+
super
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%= form_for(@page) do |f| %>
|
|
2
|
+
<% if @page.errors.any? %>
|
|
3
|
+
<div id="error_explanation">
|
|
4
|
+
<h2><%= pluralize(@page.errors.count, "error") %> prohibited this page from being saved:</h2>
|
|
5
|
+
|
|
6
|
+
<ul>
|
|
7
|
+
<% @page.errors.full_messages.each do |message| %>
|
|
8
|
+
<li><%= message %></li>
|
|
9
|
+
<% end %>
|
|
10
|
+
</ul>
|
|
11
|
+
</div>
|
|
12
|
+
<% end %>
|
|
13
|
+
|
|
14
|
+
<div class="field">
|
|
15
|
+
<%= f.label :title %><br>
|
|
16
|
+
<%= f.text_field :title %>
|
|
17
|
+
</div>
|
|
18
|
+
<div class="field">
|
|
19
|
+
<%= f.label :featured %><br>
|
|
20
|
+
<%= f.check_box :featured %>
|
|
21
|
+
</div>
|
|
22
|
+
<div class="field">
|
|
23
|
+
<%= f.label :text %><br>
|
|
24
|
+
<%= f.text_area :text, :class => "tinymce", :rows => 20, :cols => 80 %>
|
|
25
|
+
</div>
|
|
26
|
+
<%= tinymce %>
|
|
27
|
+
<div class="actions">
|
|
28
|
+
<%= f.submit %>
|
|
29
|
+
</div>
|
|
30
|
+
<% end %>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<p id="notice"><%= notice %></p>
|
|
2
|
+
|
|
3
|
+
<h3>Listing Pages</h3>
|
|
4
|
+
|
|
5
|
+
<table>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<th>Title</th>
|
|
9
|
+
<th>Featured</th>
|
|
10
|
+
<th colspan="3"></th>
|
|
11
|
+
</tr>
|
|
12
|
+
</thead>
|
|
13
|
+
|
|
14
|
+
<tbody>
|
|
15
|
+
<% @pages.each do |page| %>
|
|
16
|
+
<tr>
|
|
17
|
+
<td><%= page.title %></td>
|
|
18
|
+
<td><%= page.featured %></td>
|
|
19
|
+
<td><%= link_to 'Show', page %></td>
|
|
20
|
+
<td><%= link_to 'Edit', edit_page_path(page) %></td>
|
|
21
|
+
<td><%= link_to 'Destroy', page, method: :delete, data: { confirm: "Are you sure?" } %></td>
|
|
22
|
+
</tr>
|
|
23
|
+
<% end %>
|
|
24
|
+
</tbody>
|
|
25
|
+
</table>
|
|
26
|
+
|
|
27
|
+
<br>
|
|
28
|
+
|
|
29
|
+
<%= link_to 'New Page', new_page_path %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
require 'rails/generators/base'
|
|
2
|
+
|
|
3
|
+
module Paginas
|
|
4
|
+
module Generators
|
|
5
|
+
# Include this module in your generator to generate paginas views.
|
|
6
|
+
# `copy_views` is the main method and by default copies all views
|
|
7
|
+
# with forms.
|
|
8
|
+
module ViewPathTemplates #:nodoc:
|
|
9
|
+
extend ActiveSupport::Concern
|
|
10
|
+
|
|
11
|
+
included do
|
|
12
|
+
argument :scope, required: false, default: nil,
|
|
13
|
+
desc: "The scope to copy views to"
|
|
14
|
+
|
|
15
|
+
# Le sigh, ensure Thor won't handle opts as args
|
|
16
|
+
# It should be fixed in future Rails releases
|
|
17
|
+
class_option :form_builder, aliases: "-b"
|
|
18
|
+
class_option :markerb
|
|
19
|
+
class_option :views, aliases: "-v", type: :array, desc: "Select specific view directories to generate (pages)"
|
|
20
|
+
|
|
21
|
+
public_task :copy_views
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# TODO: Add this to Rails itself
|
|
25
|
+
module ClassMethods
|
|
26
|
+
def hide!
|
|
27
|
+
Rails::Generators.hide_namespace self.namespace
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def copy_views
|
|
32
|
+
if options[:views]
|
|
33
|
+
options[:views].each do |directory|
|
|
34
|
+
view_directory directory.to_sym
|
|
35
|
+
end
|
|
36
|
+
else
|
|
37
|
+
view_directory :pages
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
protected
|
|
42
|
+
|
|
43
|
+
def view_directory(name, _target_path = nil)
|
|
44
|
+
directory name.to_s, _target_path || "#{target_path}/#{name}" do |content|
|
|
45
|
+
if scope
|
|
46
|
+
content.gsub "paginas/shared/links", "#{scope}/shared/links"
|
|
47
|
+
else
|
|
48
|
+
content
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def target_path
|
|
54
|
+
@target_path ||= "app/views/#{scope || :paginas}"
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
class SharedViewsGenerator < Rails::Generators::Base #:nodoc:
|
|
59
|
+
include ViewPathTemplates
|
|
60
|
+
source_root File.expand_path("../../../../app/views/paginas", __FILE__)
|
|
61
|
+
desc "Copies shared Paginas views to your application."
|
|
62
|
+
hide!
|
|
63
|
+
|
|
64
|
+
# Override copy_views to just copy mailer and shared.
|
|
65
|
+
def copy_views
|
|
66
|
+
view_directory :shared
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class FormForGenerator < Rails::Generators::Base #:nodoc:
|
|
71
|
+
include ViewPathTemplates
|
|
72
|
+
source_root File.expand_path("../../../../app/views/paginas", __FILE__)
|
|
73
|
+
desc "Copies default Paginas views to your application."
|
|
74
|
+
hide!
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
class ViewsGenerator < Rails::Generators::Base
|
|
78
|
+
desc "Copies Paginas views to your application."
|
|
79
|
+
|
|
80
|
+
argument :scope, required: false, default: nil,
|
|
81
|
+
desc: "The scope to copy views to"
|
|
82
|
+
|
|
83
|
+
invoke SharedViewsGenerator
|
|
84
|
+
|
|
85
|
+
hook_for :form_builder, aliases: "-b",
|
|
86
|
+
desc: "Form builder to be used",
|
|
87
|
+
default: defined?(SimpleForm) ? "simple_form_for" : "form_for"
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|