beautiful_scaffold 0.0.1 → 0.0.6
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.
- data/Gemfile +21 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +10 -0
- data/beautiful_scaffold.gemspec +18 -0
- data/lib/generators/USAGE +15 -0
- data/lib/generators/beautiful_locale_generator.rb +34 -0
- data/lib/generators/beautiful_migration_generator.rb +53 -0
- data/lib/generators/beautiful_scaffold_common_methods.rb +104 -0
- data/lib/generators/beautiful_scaffold_generator.rb +158 -0
- data/lib/generators/templates/app/assets/images/bg-bottom-login.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-error.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-left.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-notice.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-notice.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-success.png +0 -0
- data/lib/generators/templates/app/assets/images/bg-top-login.jpg +0 -0
- data/lib/generators/templates/app/assets/images/bg-warning.png +0 -0
- data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +80 -0
- data/lib/generators/templates/app/assets/javascripts/jquery.pjax.js +370 -0
- data/lib/generators/templates/app/assets/javascripts/modernizr.custom.js +4 -0
- data/lib/generators/templates/app/assets/stylesheets/beautiful_scaffold.css.scss +719 -0
- data/lib/generators/templates/app/assets/stylesheets/reset.css +48 -0
- data/lib/generators/templates/app/controllers/base.rb +177 -0
- data/lib/generators/templates/app/controllers/master_base.rb +37 -0
- data/lib/generators/templates/app/helpers/beautiful_helper.rb +130 -0
- data/lib/generators/templates/app/helpers/model_helper.rb +4 -0
- data/lib/generators/templates/app/locales/beautiful_scaffold.en.yml +30 -0
- data/lib/generators/templates/app/locales/beautiful_scaffold.fr.yml +30 -0
- data/lib/generators/templates/app/models/pdf_report.rb +40 -0
- data/lib/generators/templates/app/views/_beautiful_menu.html.erb +9 -0
- data/lib/generators/templates/app/views/_form.html.erb +24 -0
- data/lib/generators/templates/app/views/edit.html.erb +6 -0
- data/lib/generators/templates/app/views/index.html.erb +86 -0
- data/lib/generators/templates/app/views/layout.html.erb +70 -0
- data/lib/generators/templates/app/views/new.html.erb +5 -0
- data/lib/generators/templates/app/views/partials/_form_field.html.erb +37 -0
- data/lib/generators/templates/app/views/partials/_index_batch.html.erb +6 -0
- data/lib/generators/templates/app/views/partials/_index_column.html.erb +19 -0
- data/lib/generators/templates/app/views/partials/_index_header.html.erb +9 -0
- data/lib/generators/templates/app/views/partials/_index_search.html.erb +10 -0
- data/lib/generators/templates/app/views/partials/_show_field.html.erb +14 -0
- data/lib/generators/templates/app/views/show.html.erb +7 -0
- data/lib/generators/templates/markitup/jquery.markitup.js +593 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/fonts.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-item.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/images/underline.png +0 -0
- data/lib/generators/templates/markitup/sets/bbcode/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/bbcode/set.js +39 -0
- data/lib/generators/templates/markitup/sets/bbcode/style.css +47 -0
- data/lib/generators/templates/markitup/sets/default/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/image.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/default/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/default/set.js +30 -0
- data/lib/generators/templates/markitup/sets/default/style.css +34 -0
- data/lib/generators/templates/markitup/sets/html/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/clean.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/image.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-item.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/paragraph.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/html/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/html/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/html/set.js +39 -0
- data/lib/generators/templates/markitup/sets/html/style.css +59 -0
- data/lib/generators/templates/markitup/sets/markdown/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/markdown/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/markdown/set.js +52 -0
- data/lib/generators/templates/markitup/sets/markdown/style.css +54 -0
- data/lib/generators/templates/markitup/sets/textile/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/paragraph.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/textile/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/textile/set.js +40 -0
- data/lib/generators/templates/markitup/sets/textile/style.css +60 -0
- data/lib/generators/templates/markitup/sets/wiki/images/bold.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/code.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h1.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h2.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h3.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h4.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h5.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/h6.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/italic.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/link.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/list-bullet.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/list-numeric.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/picture.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/preview.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/quotes.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/stroke.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/images/url.png +0 -0
- data/lib/generators/templates/markitup/sets/wiki/readme.txt +11 -0
- data/lib/generators/templates/markitup/sets/wiki/set.js +37 -0
- data/lib/generators/templates/markitup/sets/wiki/style.css +57 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-container.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-bbcode.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-dotclear.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-html.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-json.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-markdown.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-textile.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-wiki.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor-xml.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/bg-editor.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/handle.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/menu.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/images/submenu.png +0 -0
- data/lib/generators/templates/markitup/skins/markitup/style.css +147 -0
- data/lib/generators/templates/markitup/skins/simple/images/handle.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/images/menu.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/images/submenu.png +0 -0
- data/lib/generators/templates/markitup/skins/simple/style.css +118 -0
- data/lib/generators/templates/markitup/templates/preview.css +5 -0
- data/lib/generators/templates/markitup/templates/preview.html +11 -0
- data/lib/generators/templates/modules/beautiful_scaffold_module.rb +28 -0
- metadata +175 -3
data/Gemfile
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
source "http://rubygems.org"
|
|
2
|
+
|
|
3
|
+
gemspec
|
|
4
|
+
|
|
5
|
+
gem "rails"
|
|
6
|
+
# Pagination
|
|
7
|
+
gem "will_paginate"
|
|
8
|
+
# Search and filter
|
|
9
|
+
gem "ransack"
|
|
10
|
+
# Pdf
|
|
11
|
+
gem 'prawn', '1.0.0.rc1'
|
|
12
|
+
# Textile
|
|
13
|
+
gem 'RedCloth'
|
|
14
|
+
# BBCode
|
|
15
|
+
gem 'bb-ruby'
|
|
16
|
+
# Markdown
|
|
17
|
+
gem 'bluecloth'
|
|
18
|
+
# Markdown
|
|
19
|
+
gem 'rdiscount'
|
|
20
|
+
# Clear html tag
|
|
21
|
+
gem 'sanitize'
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2011 Claudel Sylvain (rivsc). http://blog.escarworld.com
|
|
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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Beautiful Scaffold is a gem which propose generators for a complete scaffold with paginate, sort and filter.
|
|
2
|
+
Fully customizable.
|
|
3
|
+
|
|
4
|
+
rails generate beautiful_scaffold mode attr:type attr:type... [--namespace=name]
|
|
5
|
+
|
|
6
|
+
# Example : products
|
|
7
|
+
rails generate beautiful_scaffold product name:string price:price tva:float description:richtext visible:boolean && rake db:migrate
|
|
8
|
+
|
|
9
|
+
# Example : admin products
|
|
10
|
+
rails generate beautiful_scaffold product name:string price:price tva:float description:richtext overview_description:richtext visible:boolean --namespace=admin && rake db:migrate
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
+
|
|
4
|
+
Gem::Specification.new do |s|
|
|
5
|
+
s.name = "beautiful_scaffold"
|
|
6
|
+
s.version = "0.0.6"
|
|
7
|
+
s.platform = Gem::Platform::RUBY
|
|
8
|
+
s.summary = "Beautiful Scaffold generate fully customizable scaffold"
|
|
9
|
+
s.email = "claudel.sylvain@gmail.com"
|
|
10
|
+
s.homepage = "http://beautiful-scaffold.com"
|
|
11
|
+
s.description = "Beautiful Scaffold generate a complete scaffold (sort, export, paginate and filter data)"
|
|
12
|
+
s.authors = ['Sylvain Claudel']
|
|
13
|
+
s.files = `git ls-files`.split("\n")
|
|
14
|
+
|
|
15
|
+
s.rubyforge_project = "beautiful_scaffold"
|
|
16
|
+
|
|
17
|
+
s.require_paths = ["lib","lib/generators"]
|
|
18
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
scaffold, migration and locale
|
|
3
|
+
|
|
4
|
+
Example:
|
|
5
|
+
rails generate beautiful_scaffold model attribute:type attribute:type ...
|
|
6
|
+
rails generate beautiful scaffold price:price name:string visible:boolean description:richtext
|
|
7
|
+
rails generate beautiful_scaffold product family:references price:price name:string visible:boolean description:richtext
|
|
8
|
+
|
|
9
|
+
rails generate beautiful_migration AddColorToProducts color:string
|
|
10
|
+
|
|
11
|
+
rails generate beautiful_locale {fr|en|all}
|
|
12
|
+
|
|
13
|
+
This will create:
|
|
14
|
+
what/will/it/create
|
|
15
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# encoding : utf-8
|
|
2
|
+
class BeautifulLocaleGenerator < Rails::Generators::Base
|
|
3
|
+
require 'beautiful_scaffold_common_methods'
|
|
4
|
+
include BeautifulScaffoldCommonMethods
|
|
5
|
+
|
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
7
|
+
|
|
8
|
+
argument :name, :type => :string, :desc => "type of locale : fr OR en OR de OR all..."
|
|
9
|
+
|
|
10
|
+
def install_locale
|
|
11
|
+
availablelocale = ["fr", "en"]
|
|
12
|
+
|
|
13
|
+
localestr = name.downcase
|
|
14
|
+
|
|
15
|
+
locale_to_process = []
|
|
16
|
+
if availablelocale.include?(localestr) then
|
|
17
|
+
locale_to_process << localestr
|
|
18
|
+
elsif localestr == 'all' then
|
|
19
|
+
locale_to_process = availablelocale
|
|
20
|
+
else
|
|
21
|
+
puts "This locale #{localestr} doesn't exist !"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
locale_to_process.each{ |temp_locale|
|
|
25
|
+
filename = "beautiful_scaffold.#{temp_locale}.yml"
|
|
26
|
+
gem_localepath = "app/locales/#{filename}"
|
|
27
|
+
app_localepath = "config/locales/#{filename}"
|
|
28
|
+
copy_file gem_localepath, app_localepath
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
puts "/!\\ Remember to download rails locale and update your application.rb file !"
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# encoding : utf-8
|
|
2
|
+
class BeautifulMigrationGenerator < Rails::Generators::Base
|
|
3
|
+
require 'beautiful_scaffold_common_methods'
|
|
4
|
+
include BeautifulScaffoldCommonMethods
|
|
5
|
+
|
|
6
|
+
#include Rails::Generators::ResourceHelpers
|
|
7
|
+
|
|
8
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
9
|
+
|
|
10
|
+
argument :name, :type => :string, :desc => "Name of the migration CamelCase AddXXXToYYY"
|
|
11
|
+
argument :myattributes, :type => :array, :default => [], :banner => "field:type field:type"
|
|
12
|
+
class_option :namespace, :default => nil
|
|
13
|
+
|
|
14
|
+
def add_field_for_fulltext
|
|
15
|
+
@beautiful_attributes = myattributes.dup
|
|
16
|
+
@fulltext_field = []
|
|
17
|
+
myattributes.each{ |attr|
|
|
18
|
+
a,t = attr.split(':')
|
|
19
|
+
if t == 'richtext' then
|
|
20
|
+
# _typetext = {bbcode|html|text|wiki|textile|markdown}
|
|
21
|
+
# _fulltext = text without any code
|
|
22
|
+
@fulltext_field << [a + '_typetext', 'string'].join(':')
|
|
23
|
+
@fulltext_field << [a + '_fulltext', 'text'].join(':')
|
|
24
|
+
end
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def generate_model
|
|
29
|
+
generate("migration", "#{name} #{beautiful_attr_to_rails_attr.join(' ')} #{@fulltext_field.join(' ')}")
|
|
30
|
+
# TODO pour les references mettre _id et integer
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def generate_views
|
|
34
|
+
commonpath = "app/views/#{namespace_for_url}#{model_pluralize}/"
|
|
35
|
+
|
|
36
|
+
# Form
|
|
37
|
+
inject_into_file("#{commonpath}_form.html.erb", render_partial("app/views/partials/_form_field.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Do not remove -->\n" )
|
|
38
|
+
# Index
|
|
39
|
+
inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_batch.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Batch - Do not remove -->\n" )
|
|
40
|
+
inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_header.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Header - Do not remove -->\n" )
|
|
41
|
+
inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_column.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Column - Do not remove -->\n" )
|
|
42
|
+
inject_into_file("#{commonpath}index.html.erb", render_partial("app/views/partials/_index_search.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Search - Do not remove -->\n" )
|
|
43
|
+
# Show
|
|
44
|
+
inject_into_file("#{commonpath}show.html.erb", render_partial("app/views/partials/_show_field.html.erb"), :before => "<!-- Beautiful_scaffold - AddField - Field - Do not remove -->\n" )
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def model
|
|
50
|
+
return name.scan(/^Add(.*)To(.*)$/).flatten[1].underscore.singularize
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
module BeautifulScaffoldCommonMethods
|
|
2
|
+
require 'erb'
|
|
3
|
+
|
|
4
|
+
private
|
|
5
|
+
|
|
6
|
+
def namespace_for_class
|
|
7
|
+
str = namespace_alone
|
|
8
|
+
if not str.blank? then
|
|
9
|
+
str = str.camelcase + '::'
|
|
10
|
+
end
|
|
11
|
+
return str
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def namespace_for_route
|
|
15
|
+
str = namespace_alone
|
|
16
|
+
if not str.blank? then
|
|
17
|
+
str = str.downcase + '_'
|
|
18
|
+
end
|
|
19
|
+
return str
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def namespace_for_url
|
|
23
|
+
str = namespace_alone
|
|
24
|
+
if not str.blank? then
|
|
25
|
+
str = str.downcase + '/'
|
|
26
|
+
end
|
|
27
|
+
return str
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def namespace_alone
|
|
31
|
+
return options[:namespace].to_s.downcase
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def render_partial(path)
|
|
35
|
+
source = File.expand_path(find_in_source_paths(path.to_s))
|
|
36
|
+
result = ERB.new(::File.binread(source), nil, '-').result(binding)
|
|
37
|
+
return result
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def model_camelize
|
|
41
|
+
model.camelize
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def model_pluralize
|
|
45
|
+
model.pluralize
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def model_class
|
|
49
|
+
model.classify
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# For the views
|
|
53
|
+
def plural_table_name
|
|
54
|
+
model_pluralize
|
|
55
|
+
end
|
|
56
|
+
def singular_table_name
|
|
57
|
+
model
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def available_views
|
|
61
|
+
%w(index edit show new _form)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def attributes
|
|
65
|
+
# https://raw.github.com/rails/rails/master/railties/lib/rails/generators/generated_attribute.rb
|
|
66
|
+
return myattributes.map{ |a|
|
|
67
|
+
require 'rails/generators/generated_attribute'
|
|
68
|
+
Rails::Generators::GeneratedAttribute.new(*a.split(":"))
|
|
69
|
+
}
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def beautiful_attr_to_rails_attr
|
|
73
|
+
newmyattributes = []
|
|
74
|
+
myattributes.each{ |attr|
|
|
75
|
+
a,t = attr.split(':')
|
|
76
|
+
newt = t
|
|
77
|
+
if t == 'richtext' then
|
|
78
|
+
newt = 'text'
|
|
79
|
+
elsif t == 'price' then
|
|
80
|
+
newt = 'float'
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
newmyattributes << [a, newt].join(':')
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return newmyattributes
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def fulltext_attribute
|
|
90
|
+
fulltext_field = []
|
|
91
|
+
myattributes.each{ |attr|
|
|
92
|
+
a,t = attr.split(':')
|
|
93
|
+
if t == 'richtext' then
|
|
94
|
+
fulltext_field << a
|
|
95
|
+
end
|
|
96
|
+
}
|
|
97
|
+
return fulltext_field
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def richtext_type
|
|
101
|
+
return ["bbcode","html","text","wiki","textile","markdown"]
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
end
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# encoding : utf-8
|
|
2
|
+
class BeautifulScaffoldGenerator < Rails::Generators::Base
|
|
3
|
+
require 'beautiful_scaffold_common_methods'
|
|
4
|
+
include BeautifulScaffoldCommonMethods
|
|
5
|
+
|
|
6
|
+
# Resources
|
|
7
|
+
# Generator : http://guides.rubyonrails.org/generators.html
|
|
8
|
+
# ActiveAdmin with MetaSearch : https://github.com/gregbell/active_admin/tree/master/lib/active_admin
|
|
9
|
+
# MetaSearch and ransack : https://github.com/ernie/meta_search & http://erniemiller.org/projects/metasearch/#description & http://github.com/ernie/ransack
|
|
10
|
+
# Generator of rails : https://github.com/rails/rails/blob/master/railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
|
|
11
|
+
|
|
12
|
+
#include Rails::Generators::ResourceHelpers
|
|
13
|
+
|
|
14
|
+
source_root File.expand_path('../templates', __FILE__)
|
|
15
|
+
|
|
16
|
+
argument :model, :type => :string, :desc => "Name of model (downcase singular)"
|
|
17
|
+
argument :myattributes, :type => :array, :default => [], :banner => "field:type field:type"
|
|
18
|
+
|
|
19
|
+
class_option :namespace, :default => nil
|
|
20
|
+
|
|
21
|
+
def add_field_for_fulltext
|
|
22
|
+
@beautiful_attributes = myattributes.dup
|
|
23
|
+
@fulltext_field = []
|
|
24
|
+
myattributes.each{ |attr|
|
|
25
|
+
a,t = attr.split(':')
|
|
26
|
+
if t == 'richtext' then
|
|
27
|
+
# _typetext = {bbcode|html|text|wiki|textile|markdown}
|
|
28
|
+
# _fulltext = text without any code
|
|
29
|
+
@fulltext_field << [a + '_typetext', 'string'].join(':')
|
|
30
|
+
@fulltext_field << [a + '_fulltext', 'text'].join(':')
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def mimetype
|
|
36
|
+
if not File.exist?("app/controllers/beautiful_controller.rb") then
|
|
37
|
+
inject_into_file("config/initializers/mime_types.rb", 'Mime::Type.register_alias "application/pdf", :pdf' + "\n", :before => "# Be sure to restart your server when you modify this file." )
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def generate_assets
|
|
42
|
+
stylesheetspath = "app/assets/stylesheets/"
|
|
43
|
+
|
|
44
|
+
# Css
|
|
45
|
+
reset = "#{stylesheetspath}reset.css"
|
|
46
|
+
bc_css = "#{stylesheetspath}beautiful_scaffold.css.scss"
|
|
47
|
+
|
|
48
|
+
javascriptspath = "app/assets/javascripts/"
|
|
49
|
+
|
|
50
|
+
# Js
|
|
51
|
+
bc_js = "#{javascriptspath}beautiful_scaffold.js"
|
|
52
|
+
pjax_js = "#{javascriptspath}jquery.pjax.js"
|
|
53
|
+
|
|
54
|
+
[reset, bc_css, bc_js, pjax_js].each{ |path|
|
|
55
|
+
copy_file path, path
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
# Images
|
|
59
|
+
dir_image = "app/assets/images"
|
|
60
|
+
directory dir_image, dir_image
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def generate_layout
|
|
64
|
+
template "app/views/layout.html.erb", "app/views/layouts/beautiful_layout.html.erb"
|
|
65
|
+
if not File.exist?("app/views/layouts/_beautiful_menu.html.erb") then
|
|
66
|
+
template "app/views/_beautiful_menu.html.erb", "app/views/layouts/_beautiful_menu.html.erb"
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
inject_into_file("app/views/layouts/_beautiful_menu.html.erb",'
|
|
70
|
+
<p class="menuelt <%= "active" if params[:controller] == "' + namespace_for_url + model.pluralize + '" %>" data-id="sub-' + model + '">' + model.capitalize + '</p>
|
|
71
|
+
<ul class="submenu <%= "hidden" if params[:controller] != "' + namespace_for_url + model.pluralize + '" %>" id="sub-' + model + '">
|
|
72
|
+
<li><%= link_to "New ' + model.capitalize + '", new_' + namespace_for_route + model + '_path %></li>
|
|
73
|
+
<li><%= link_to "Manage ' + model.capitalize.pluralize + '", ' + namespace_for_route + model.pluralize + '_path %></li>
|
|
74
|
+
</ul>', :after => "<!-- Beautiful Scaffold Menu Do Not Touch This -->")
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def install_markitup
|
|
78
|
+
# CSS
|
|
79
|
+
directory "markitup/skins", "app/assets/stylesheets/markitup/skins"
|
|
80
|
+
# JS
|
|
81
|
+
copy_file "markitup/jquery.markitup.js", "app/assets/javascripts/jquery.markitup.js"
|
|
82
|
+
# JS and CSS
|
|
83
|
+
directory "markitup/sets", "app/assets/stylesheets/markitup/sets"
|
|
84
|
+
directory "markitup/sets", "app/assets/javascripts/markitup/sets"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def generate_model
|
|
88
|
+
generate("model", "#{model} #{beautiful_attr_to_rails_attr.join(' ')} #{@fulltext_field.join(' ')}")
|
|
89
|
+
|
|
90
|
+
inject_into_file("app/models/#{model}.rb",'
|
|
91
|
+
scope :sorting, lambda{ |options|
|
|
92
|
+
attribute = options[:attribute]
|
|
93
|
+
direction = options[:sorting]
|
|
94
|
+
|
|
95
|
+
attribute ||= "id"
|
|
96
|
+
direction ||= "DESC"
|
|
97
|
+
|
|
98
|
+
order("#{attribute} #{direction}")
|
|
99
|
+
}
|
|
100
|
+
# You can OVERRIDE this method used in model form and search form (in belongs_to relation)
|
|
101
|
+
def caption
|
|
102
|
+
"#" + id.to_s
|
|
103
|
+
end', :after => "class #{model_camelize} < ActiveRecord::Base")
|
|
104
|
+
|
|
105
|
+
inject_into_file("app/models/#{model}.rb",'
|
|
106
|
+
include BeautifulScaffoldModule
|
|
107
|
+
|
|
108
|
+
before_save :fulltext_field_processing
|
|
109
|
+
|
|
110
|
+
def fulltext_field_processing
|
|
111
|
+
# You can preparse with own things here
|
|
112
|
+
generate_fulltext_field([' + fulltext_attribute.map{ |e| ('"' + e + '"') }.join(",") + '])
|
|
113
|
+
end', :after => "class #{model_camelize} < ActiveRecord::Base")
|
|
114
|
+
|
|
115
|
+
inject_into_file("config/application.rb", ' config.autoload_paths += %W(#{config.root}/app/modules)' + "\n", :after => "< Rails::Application\n")
|
|
116
|
+
|
|
117
|
+
directory "modules", "app/modules"
|
|
118
|
+
copy_file "app/models/pdf_report.rb", "app/models/pdf_report.rb"
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def generate_controller
|
|
122
|
+
copy_file "app/controllers/master_base.rb", "app/controllers/beautiful_controller.rb"
|
|
123
|
+
dirs = ['app', 'controllers', options[:namespace]].compact
|
|
124
|
+
empty_directory File.join(dirs)
|
|
125
|
+
template "app/controllers/base.rb", File.join([dirs, "#{model_pluralize}_controller.rb"].flatten)
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
def generate_helper
|
|
129
|
+
copy_file "app/helpers/beautiful_helper.rb", "app/helpers/beautiful_helper.rb"
|
|
130
|
+
dirs = ['app', 'helpers', options[:namespace]].compact
|
|
131
|
+
empty_directory File.join(dirs)
|
|
132
|
+
template "app/helpers/model_helper.rb", File.join([dirs, "#{model_pluralize}_helper.rb"].flatten)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def generate_views
|
|
136
|
+
namespacedirs = ["app", "views", options[:namespace]].compact
|
|
137
|
+
empty_directory File.join(namespacedirs)
|
|
138
|
+
|
|
139
|
+
dirs = [namespacedirs, model_pluralize]
|
|
140
|
+
empty_directory File.join(dirs)
|
|
141
|
+
|
|
142
|
+
available_views.each do |view|
|
|
143
|
+
filename = view + ".html.erb"
|
|
144
|
+
current_template_path = File.join([dirs, filename].flatten)
|
|
145
|
+
empty_template_path = File.join(["app", "views", filename].flatten)
|
|
146
|
+
|
|
147
|
+
template empty_template_path, current_template_path
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
def routes
|
|
152
|
+
myroute = ""
|
|
153
|
+
myroute += "namespace :#{namespace_alone} do\n " if not namespace_alone.blank?
|
|
154
|
+
myroute += "resources :#{model_pluralize} do\n collection do\n post :batch\n end\n end\n"
|
|
155
|
+
myroute += "end\n" if not namespace_alone.blank?
|
|
156
|
+
route(myroute)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
$(document).ready(function(){
|
|
2
|
+
|
|
3
|
+
/* Menu */
|
|
4
|
+
$(".menuelt").click(function(){
|
|
5
|
+
$(".menuelt").removeClass("active");
|
|
6
|
+
$(this).addClass("active");
|
|
7
|
+
|
|
8
|
+
idsubmenu = $(this).attr('data-id');
|
|
9
|
+
$(".submenu").addClass("hidden");
|
|
10
|
+
$("#"+idsubmenu).removeClass("hidden");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/* Box */
|
|
14
|
+
$(".box-title").click(function(){
|
|
15
|
+
p = $(this).parent();
|
|
16
|
+
if(p.hasClass("close")){
|
|
17
|
+
p.removeClass("close",500)
|
|
18
|
+
}else{
|
|
19
|
+
p.addClass("close",500)
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
/* Flash */
|
|
24
|
+
$("#flash-warning,#flash-notice,#flash-success,#flash-error").click(function(){
|
|
25
|
+
$(this).fadeOut(1000, function(){
|
|
26
|
+
$(this).remove();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
/* Richtext editor */
|
|
31
|
+
$('.select-richtext').click(function(){
|
|
32
|
+
$('.label-richtext-type[for=' + $(this).attr('id') + ']').trigger('click');
|
|
33
|
+
});
|
|
34
|
+
$('.label-richtext-type').live("click", function(){
|
|
35
|
+
elt = $('#' + $(this).attr('for'));
|
|
36
|
+
newSet = elt.val();
|
|
37
|
+
idspleditor = elt.attr('data-spleditor');
|
|
38
|
+
ideditor = elt.attr('data-editor');
|
|
39
|
+
$('#' + idspleditor).markItUpRemove();
|
|
40
|
+
if(!$('#' + idspleditor).hasClass('markItUpEditor')){
|
|
41
|
+
switch(newSet) {
|
|
42
|
+
case 'bbcode':
|
|
43
|
+
$('#' + idspleditor).markItUp(myBbcodeSettings);
|
|
44
|
+
break;
|
|
45
|
+
case 'wiki':
|
|
46
|
+
$('#' + idspleditor).markItUp(myWikiSettings);
|
|
47
|
+
break;
|
|
48
|
+
case 'textile':
|
|
49
|
+
$('#' + idspleditor).markItUp(myTextileSettings);
|
|
50
|
+
break;
|
|
51
|
+
case 'markdown':
|
|
52
|
+
$('#' + idspleditor).markItUp(myMarkdownSettings);
|
|
53
|
+
break;
|
|
54
|
+
case 'html':
|
|
55
|
+
$('#' + idspleditor).markItUp(myHtmlSettings);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
$('#' + ideditor).removeClass("bbcode html markdown textile wiki").addClass(newSet);
|
|
60
|
+
return true;
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
$(function(){
|
|
65
|
+
try{
|
|
66
|
+
/* PJAX initializer */
|
|
67
|
+
$('a:not(.nopjax)').pjax('#pjax-container').live('click');
|
|
68
|
+
$('#pjax-container').bind('pjax:start', function() {
|
|
69
|
+
$('.loader').show();
|
|
70
|
+
$("#flash-warning,#flash-notice,#flash-success,#flash-error").fadeOut(1000, function(){
|
|
71
|
+
$("#flash-warning,#flash-notice,#flash-success,#flash-error").remove();
|
|
72
|
+
});
|
|
73
|
+
}).bind('pjax:end', function() { $('.loader').hide() })
|
|
74
|
+
.bind('pjax:timeout', function() { $('.loader').show();return false; });
|
|
75
|
+
}
|
|
76
|
+
catch(err)
|
|
77
|
+
{
|
|
78
|
+
//Handle errors here
|
|
79
|
+
}
|
|
80
|
+
});
|