humpyard 0.0.1
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 +28 -0
- data/README.rdoc +61 -0
- data/VERSION +1 -0
- data/app/controllers/humpyard/assets_controller.rb +123 -0
- data/app/controllers/humpyard/elements_controller.rb +200 -0
- data/app/controllers/humpyard/errors_controller.rb +8 -0
- data/app/controllers/humpyard/pages_controller.rb +365 -0
- data/app/helpers/humpyard/pages_helper.rb +19 -0
- data/app/models/humpyard/asset.rb +22 -0
- data/app/models/humpyard/assets/paperclip_asset.rb +48 -0
- data/app/models/humpyard/assets/youtube_asset.rb +38 -0
- data/app/models/humpyard/element.rb +57 -0
- data/app/models/humpyard/elements/box_element.rb +15 -0
- data/app/models/humpyard/elements/media_element.rb +13 -0
- data/app/models/humpyard/elements/news_element.rb +13 -0
- data/app/models/humpyard/elements/sitemap_element.rb +11 -0
- data/app/models/humpyard/elements/text_element.rb +49 -0
- data/app/models/humpyard/news_item.rb +42 -0
- data/app/models/humpyard/page.rb +153 -0
- data/app/models/humpyard/pages/news_page.rb +71 -0
- data/app/models/humpyard/pages/static_page.rb +25 -0
- data/app/models/humpyard/pages/virtual_page.rb +30 -0
- data/app/views/humpyard/assets/_edit.html.haml +15 -0
- data/app/views/humpyard/assets/_index.html.haml +24 -0
- data/app/views/humpyard/assets/_list.html.haml +4 -0
- data/app/views/humpyard/assets/_list_item.html.haml +1 -0
- data/app/views/humpyard/assets/_show.html.haml +38 -0
- data/app/views/humpyard/assets/_show_asset.html.haml +3 -0
- data/app/views/humpyard/assets/destroy.js.erb +4 -0
- data/app/views/humpyard/assets/paperclip_assets/_edit.html.haml +4 -0
- data/app/views/humpyard/assets/paperclip_assets/_info_table.html.haml +10 -0
- data/app/views/humpyard/assets/paperclip_assets/_show.html.haml +12 -0
- data/app/views/humpyard/assets/youtube_assets/_edit.html.haml +4 -0
- data/app/views/humpyard/assets/youtube_assets/_show.html.haml +5 -0
- data/app/views/humpyard/common/_head.html.haml +8 -0
- data/app/views/humpyard/common/_page_construct.html.haml +45 -0
- data/app/views/humpyard/elements/_edit.html.haml +25 -0
- data/app/views/humpyard/elements/_inline_edit.haml +0 -0
- data/app/views/humpyard/elements/_new.html.haml +1 -0
- data/app/views/humpyard/elements/_show.html.haml +29 -0
- data/app/views/humpyard/elements/_show_container.html.haml +3 -0
- data/app/views/humpyard/elements/_show_view.html.haml +2 -0
- data/app/views/humpyard/elements/box_elements/_edit.html.haml +4 -0
- data/app/views/humpyard/elements/box_elements/_inline_edit.html.haml +0 -0
- data/app/views/humpyard/elements/box_elements/_show.html.haml +5 -0
- data/app/views/humpyard/elements/destroy.js.erb +1 -0
- data/app/views/humpyard/elements/error.js.erb +1 -0
- data/app/views/humpyard/elements/media_elements/_edit.html.haml +7 -0
- data/app/views/humpyard/elements/media_elements/_show.html.haml +8 -0
- data/app/views/humpyard/elements/news_elements/_edit.html.haml +5 -0
- data/app/views/humpyard/elements/news_elements/_inline_edit.html.haml +0 -0
- data/app/views/humpyard/elements/news_elements/_show.html.haml +4 -0
- data/app/views/humpyard/elements/sitemap_elements/_edit.html.haml +5 -0
- data/app/views/humpyard/elements/sitemap_elements/_inline_edit.html.haml +0 -0
- data/app/views/humpyard/elements/sitemap_elements/_show.html.haml +3 -0
- data/app/views/humpyard/elements/sitemap_elements/_show_part.html.haml +12 -0
- data/app/views/humpyard/elements/text_elements/_edit.html.haml +4 -0
- data/app/views/humpyard/elements/text_elements/_inline_edit.html.haml +0 -0
- data/app/views/humpyard/elements/text_elements/_show.html.haml +4 -0
- data/app/views/humpyard/pages/_content.html.haml +2 -0
- data/app/views/humpyard/pages/_edit.html.haml +39 -0
- data/app/views/humpyard/pages/_index.html.haml +23 -0
- data/app/views/humpyard/pages/_show.html.haml +16 -0
- data/app/views/humpyard/pages/_subtree.html.haml +6 -0
- data/app/views/humpyard/pages/_tree.html.haml +3 -0
- data/app/views/humpyard/pages/destroy.js.erb +4 -0
- data/app/views/humpyard/pages/news_pages/_detail.html.haml +10 -0
- data/app/views/humpyard/pages/news_pages/_edit.html.haml +3 -0
- data/app/views/humpyard/pages/news_pages/_show.html.haml +5 -0
- data/app/views/humpyard/pages/show.html.haml +3 -0
- data/app/views/humpyard/pages/static_pages/_edit.html.haml +1 -0
- data/app/views/humpyard/pages/static_pages/_show.html.haml +1 -0
- data/app/views/humpyard/pages/virtual_pages/_edit.html.haml +7 -0
- data/app/views/humpyard/pages/virtual_pages/_show.html.haml +4 -0
- data/app/views/humpyard/pages/welcome.html.haml +13 -0
- data/compass/stylesheets/_humpyard.scss +12 -0
- data/compass/stylesheets/humpyard/_backend.scss +1 -0
- data/compass/stylesheets/humpyard/_base.scss +144 -0
- data/compass/stylesheets/humpyard/_ie.scss +1 -0
- data/compass/stylesheets/humpyard/_jquery_ui_overrides.scss +380 -0
- data/compass/stylesheets/humpyard/_print.scss +3 -0
- data/config/locales/de.yml +84 -0
- data/config/locales/en.yml +81 -0
- data/config/routes.rb +38 -0
- data/db/migrate/20100321134138_base.rb +60 -0
- data/db/migrate/20100330204700_create_box_element.rb +24 -0
- data/db/migrate/20100401153655_page_template.rb +11 -0
- data/db/migrate/20100409195732_page_types.rb +26 -0
- data/db/migrate/20100413230623_element_yield.rb +14 -0
- data/db/migrate/20100415132312_news_page.rb +48 -0
- data/db/migrate/20100415193423_page_i18n_name.rb +27 -0
- data/db/migrate/20100415213700_create_news_element.rb +12 -0
- data/db/migrate/20100703120000_shared_elements.rb +9 -0
- data/db/migrate/20101001142534_page_modified_at.rb +11 -0
- data/db/migrate/20101003100138_create_sitemap_elements.rb +13 -0
- data/db/migrate/20101003122108_create_humpyard_pages_virtual_pages.rb +11 -0
- data/db/migrate/20101006070503_page_cache_control.rb +9 -0
- data/db/migrate/20101104173743_create_media.rb +36 -0
- data/db/migrate/20110425230524_media_with_link.rb +9 -0
- data/lib/generators/humpyard.rb +114 -0
- data/lib/generators/humpyard/auth/auth_generator.rb +191 -0
- data/lib/generators/humpyard/auth/templates/authlogic/README +9 -0
- data/lib/generators/humpyard/auth/templates/authlogic/controllers/user_sessions_controller.rb +22 -0
- data/lib/generators/humpyard/auth/templates/authlogic/migration.rb +17 -0
- data/lib/generators/humpyard/auth/templates/authlogic/models/ability.rb +12 -0
- data/lib/generators/humpyard/auth/templates/authlogic/models/user.rb +7 -0
- data/lib/generators/humpyard/auth/templates/authlogic/models/user_session.rb +6 -0
- data/lib/generators/humpyard/auth/templates/authlogic/views/user_sessions/new.html.haml +12 -0
- data/lib/generators/humpyard/auth/templates/custom/README +8 -0
- data/lib/generators/humpyard/auth/templates/devise/README +14 -0
- data/lib/generators/humpyard/auth/templates/devise/models/ability.rb +14 -0
- data/lib/generators/humpyard/auth/templates/fake/README +0 -0
- data/lib/generators/humpyard/auth/templates/fake/models/ability.rb +12 -0
- data/lib/generators/humpyard/auth/templates/simple/README +16 -0
- data/lib/generators/humpyard/auth/templates/simple/config/humpyard_users.yml +2 -0
- data/lib/generators/humpyard/auth/templates/simple/controllers/user_sessions_controller.rb +39 -0
- data/lib/generators/humpyard/auth/templates/simple/models/ability.rb +12 -0
- data/lib/generators/humpyard/auth/templates/simple/views/user_sessions/new.html.haml +15 -0
- data/lib/generators/humpyard/element/USAGE +7 -0
- data/lib/generators/humpyard/element/element_generator.rb +82 -0
- data/lib/generators/humpyard/element/templates/_edit.html.haml +12 -0
- data/lib/generators/humpyard/element/templates/_inline_edit.html.haml +0 -0
- data/lib/generators/humpyard/element/templates/_show.html.haml +9 -0
- data/lib/generators/humpyard/element/templates/fixtures.yml +23 -0
- data/lib/generators/humpyard/element/templates/migration.rb +16 -0
- data/lib/generators/humpyard/element/templates/model.rb +11 -0
- data/lib/generators/humpyard/element/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/humpyard/element/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/humpyard/element/templates/tests/test_unit/model.rb +7 -0
- data/lib/generators/humpyard/page/USAGE +7 -0
- data/lib/generators/humpyard/page/page_generator.rb +80 -0
- data/lib/generators/humpyard/page/templates/_edit.html.haml +7 -0
- data/lib/generators/humpyard/page/templates/_show.html.haml +4 -0
- data/lib/generators/humpyard/page/templates/fixtures.yml +23 -0
- data/lib/generators/humpyard/page/templates/migration.rb +16 -0
- data/lib/generators/humpyard/page/templates/model.rb +37 -0
- data/lib/generators/humpyard/page/templates/tests/rspec/model.rb +7 -0
- data/lib/generators/humpyard/page/templates/tests/shoulda/model.rb +7 -0
- data/lib/generators/humpyard/page/templates/tests/test_unit/model.rb +7 -0
- data/lib/generators/humpyard/skeleton/USAGE +6 -0
- data/lib/generators/humpyard/skeleton/skeleton_generator.rb +99 -0
- data/lib/generators/humpyard/skeleton/templates/compass.config +14 -0
- data/lib/generators/humpyard/skeleton/templates/images/ajax-loader.gif +0 -0
- data/lib/generators/humpyard/skeleton/templates/images/grid.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/initializers/compass.rb +16 -0
- data/lib/generators/humpyard/skeleton/templates/initializers/haml.rb +3 -0
- data/lib/generators/humpyard/skeleton/templates/initializers/humpyard.rb +20 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/images/jstree/d.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/images/jstree/throbber.gif +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-1.5.1.js +8316 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-humpyard.js +790 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-rails.js +157 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-ui-1.8.10.js +11544 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery.form-2.64.js +803 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery.jstree.js +3510 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/jquery-ui-1.8.10.css +573 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/ie.sass +15 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/ie.scss +16 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/partials/_base.sass +12 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/partials/_base.scss +11 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/print.sass +3 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/print.scss +3 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/screen.sass +78 -0
- data/lib/generators/humpyard/skeleton/templates/stylesheets/screen.scss +90 -0
- data/lib/generators/humpyard/skeleton/templates/views/layout.html.haml +28 -0
- data/lib/html_to_textile.rb +220 -0
- data/lib/humpyard.rb +70 -0
- data/lib/humpyard/action_controller/base.rb +24 -0
- data/lib/humpyard/active_model/naming.rb +29 -0
- data/lib/humpyard/active_model/translation.rb +26 -0
- data/lib/humpyard/active_model/validators/publish_range.rb +14 -0
- data/lib/humpyard/active_record/acts/asset.rb +68 -0
- data/lib/humpyard/active_record/acts/container_element.rb +26 -0
- data/lib/humpyard/active_record/acts/element.rb +89 -0
- data/lib/humpyard/active_record/acts/page.rb +101 -0
- data/lib/humpyard/active_record/has/title_for_url.rb +75 -0
- data/lib/humpyard/compass.rb +6 -0
- data/lib/humpyard/config.rb +235 -0
- data/lib/humpyard/engine.rb +7 -0
- data/lib/humpyard/uri_parser.rb +16 -0
- data/lib/humpyard/uri_parser/assets_uri_parser.rb +15 -0
- data/lib/humpyard/uri_parser/pages_uri_parser.rb +15 -0
- data/lib/tasks/humpyard.rake +103 -0
- metadata +331 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
If you did not already install Devise, you should do it now:
|
2
|
+
|
3
|
+
1. Install Devise to your Rails application running:
|
4
|
+
|
5
|
+
bundle install
|
6
|
+
rails generate devise_install
|
7
|
+
|
8
|
+
2. Create a User model running:
|
9
|
+
|
10
|
+
rails generate devise user
|
11
|
+
|
12
|
+
For options and further details see the Devise documentation:
|
13
|
+
|
14
|
+
http://github.com/plataformatec/devise
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Ability
|
2
|
+
include CanCan::Ability
|
3
|
+
|
4
|
+
def initialize(user)
|
5
|
+
# Add abilities to manage pages and elements here, e.g.:
|
6
|
+
|
7
|
+
#if user.is_admin?
|
8
|
+
# can :manage, Humpyard::Page
|
9
|
+
# can :manage, Humpyard::Element
|
10
|
+
#else
|
11
|
+
# can :read, Humpyard::Page
|
12
|
+
#end
|
13
|
+
end
|
14
|
+
end
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
You can now configure your users in
|
2
|
+
|
3
|
+
config/humpyard_users.yml
|
4
|
+
|
5
|
+
The format is
|
6
|
+
|
7
|
+
username: sha1_password
|
8
|
+
|
9
|
+
You can create passwords on the console using
|
10
|
+
|
11
|
+
require 'digest/sha1'
|
12
|
+
Digest::SHA1.hexdigest(password)
|
13
|
+
|
14
|
+
where password is the desired password.
|
15
|
+
|
16
|
+
The password for "admin" in the example yml file is "humpyard".
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class <%= class_name %>SessionsController < ApplicationController
|
2
|
+
helper 'humpyard::pages'
|
3
|
+
|
4
|
+
def new
|
5
|
+
@page = Humpyard::Page.new(
|
6
|
+
:title => I18n.t('humpyard_cms.login.title'),
|
7
|
+
:always_refresh => true,
|
8
|
+
:modified_at => Time.now,
|
9
|
+
:searchable => false
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
unless params[:username].blank? or params[:password].blank?
|
15
|
+
require 'digest/sha1'
|
16
|
+
|
17
|
+
users = YAML::load(File.open("#{RAILS_ROOT}/config/humpyard_users.yml"))
|
18
|
+
|
19
|
+
if users and "#{users[params[:username]]}" == Digest::SHA1.hexdigest(params[:password])
|
20
|
+
@current_user = params[:username]
|
21
|
+
session[:humpyard] ||= {}
|
22
|
+
session[:humpyard][:user] = @current_user
|
23
|
+
redirect_to Humpyard::Page.root_page.human_url
|
24
|
+
return
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
@login_error = true
|
29
|
+
new
|
30
|
+
render "new"
|
31
|
+
end
|
32
|
+
|
33
|
+
def destroy
|
34
|
+
@current_user = nil
|
35
|
+
session[:humpyard] ||= {}
|
36
|
+
session[:humpyard][:user] = @current_user
|
37
|
+
redirect_to Humpyard::Page.root_page.human_url
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
.login-form
|
2
|
+
- if @login_error
|
3
|
+
%p.error
|
4
|
+
%strong #{I18n.t 'humpyard_cms.login.login_error'}
|
5
|
+
= form_tag login_path do
|
6
|
+
%p
|
7
|
+
%label
|
8
|
+
#{I18n.t 'humpyard_cms.login.username'}:
|
9
|
+
= text_field_tag :username, params[:username], :class => 'field'
|
10
|
+
%p
|
11
|
+
%label
|
12
|
+
#{I18n.t 'humpyard_cms.login.password'}:
|
13
|
+
= password_field_tag :password, '', :class => 'field'
|
14
|
+
%p
|
15
|
+
= submit_tag I18n.t('humpyard_cms.login.submit'), :class => 'button'
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'generators/humpyard'
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
require 'rails/generators/migration'
|
4
|
+
require 'rails/generators/active_model'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
module Humpyard
|
8
|
+
module Generators
|
9
|
+
####
|
10
|
+
# == Element Generator
|
11
|
+
#
|
12
|
+
# rails humpyard:element ElementName [field:type field:type] [options]
|
13
|
+
#
|
14
|
+
# === Description
|
15
|
+
# The humpyard element generator creates a custom element that can
|
16
|
+
# be used inside your humpyard pages.
|
17
|
+
#
|
18
|
+
# === Options
|
19
|
+
# <tt>[--skip-model]</tt>:: Don't generate a model or migration file.
|
20
|
+
# <tt>[--skip-migration]</tt>:: Dont generate migration file for model.
|
21
|
+
# <tt>[--skip-timestamps]</tt>:: Don't add timestamps to migration file.
|
22
|
+
# <tt>[--skip-views]</tt>:: Don't generate view files.
|
23
|
+
#
|
24
|
+
# === Runtime options
|
25
|
+
# <tt>-q, [--quiet]</tt>:: Supress status output
|
26
|
+
# <tt>-p, [--pretend]</tt>:: Run but do not make any changes
|
27
|
+
# <tt>-s, [--skip]</tt>:: Skip files that already exist
|
28
|
+
# <tt>-f, [--force]</tt>:: Overwrite files that already exist
|
29
|
+
#
|
30
|
+
# === Test framework options
|
31
|
+
# <tt>[--testunit]</tt>:: Use test/unit for test files.
|
32
|
+
# <tt>[--shoulda]</tt>:: Use shoulda for test files.
|
33
|
+
# <tt>[--rspec]</tt>:: Use RSpec for test files.
|
34
|
+
# <tt>[--skip-tests]</tt>:: Don't generate test files.
|
35
|
+
#
|
36
|
+
# === Examples
|
37
|
+
# rails generate humpyard:element SimpleText text:string
|
38
|
+
# rails generate humpyard:element another_thing content:text --skip-tests
|
39
|
+
#
|
40
|
+
#
|
41
|
+
class ElementGenerator < Base
|
42
|
+
include Rails::Generators::Migration
|
43
|
+
|
44
|
+
argument :element_name, :type => :string, :required => true, :banner => 'ElementName'
|
45
|
+
|
46
|
+
include Humpyard::Generators::ModelTemplate
|
47
|
+
|
48
|
+
def create_element # :nodoc:
|
49
|
+
template 'model.rb', "app/models/#{singular_name}.rb"
|
50
|
+
unless options.skip_tests?
|
51
|
+
case test_framework
|
52
|
+
when :rspec
|
53
|
+
template "tests/rspec/model.rb", "spec/models/#{singular_name}_spec.rb"
|
54
|
+
template 'fixtures.yml', "spec/fixtures/#{plural_name}.yml"
|
55
|
+
else
|
56
|
+
template "tests/#{test_framework}/model.rb", "test/unit/#{singular_name}_test.rb"
|
57
|
+
template 'fixtures.yml', "test/fixtures/#{plural_name}.yml"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
unless options.skip_migration?
|
62
|
+
migration_template 'migration.rb', "db/migrate/create_#{plural_name.gsub('/','_')}.rb"
|
63
|
+
end
|
64
|
+
|
65
|
+
unless options.skip_views?
|
66
|
+
template '_inline_edit.html.haml', "app/views/humpyard/elements/#{plural_name}/_inline_edit.html.haml"
|
67
|
+
template '_edit.html.haml', "app/views/humpyard/elements/#{plural_name}/_edit.html.haml"
|
68
|
+
template '_show.html.haml', "app/views/humpyard/elements/#{plural_name}/_show.html.haml"
|
69
|
+
end
|
70
|
+
|
71
|
+
unless options.skip_model?
|
72
|
+
create_model options
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
def model_name
|
78
|
+
"#{element_name.camelize}Element"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/ The editing form for the element. This sits inside a tab view in a dialog.
|
2
|
+
/ These tabs are positioned at the beginning of the tab view. Example:
|
3
|
+
|
4
|
+
/ .humpyard-tab
|
5
|
+
/ .humpyard-tab-title
|
6
|
+
/ Headlines
|
7
|
+
/ = form.input :headline
|
8
|
+
/ = form.input :subheadline
|
9
|
+
/ .humpyard-tab
|
10
|
+
/ .humpyard-tab-title
|
11
|
+
/ Text Content
|
12
|
+
/ = form.input :content
|
File without changes
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/ Renders the element on the page. You can access your data model instance via element.content_data. See example below
|
2
|
+
|
3
|
+
.<%= singular_name %>
|
4
|
+
/ .headline
|
5
|
+
/ = element.content_data.headline
|
6
|
+
/ .subheadline
|
7
|
+
/ = element.content_data.subheadline
|
8
|
+
/ .content
|
9
|
+
/ = element.content_data.content
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
2
|
+
|
3
|
+
<% unless attributes.empty? -%>
|
4
|
+
one:
|
5
|
+
<% for attribute in attributes -%>
|
6
|
+
<%= attribute.name %>: <%= attribute.default %>
|
7
|
+
<% end -%>
|
8
|
+
|
9
|
+
two:
|
10
|
+
<% for attribute in attributes -%>
|
11
|
+
<%= attribute.name %>: <%= attribute.default %>
|
12
|
+
<% end -%>
|
13
|
+
<% else -%>
|
14
|
+
# This model initially had no columns defined. If you add columns to the
|
15
|
+
# model remove the '{}' from the fixture names and add the columns immediately
|
16
|
+
# below each fixture, per the syntax in the comments below
|
17
|
+
#
|
18
|
+
one: {}
|
19
|
+
# column: value
|
20
|
+
#
|
21
|
+
two: {}
|
22
|
+
# column: value
|
23
|
+
<% end -%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Create<%= plural_class_name.gsub('::', '') %> < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :<%= plural_name.gsub('/','_') %> do |t|
|
4
|
+
<%- for attribute in attributes -%>
|
5
|
+
t.<%= attribute.type %> :<%= attribute.name %>
|
6
|
+
<%- end -%>
|
7
|
+
<%- unless options[:skip_timestamps] -%>
|
8
|
+
t.timestamps
|
9
|
+
<%- end -%>
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :<%= plural_name.gsub('/','_') %>
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class <%= class_name %> < ActiveRecord::Base
|
2
|
+
acts_as_humpyard_element
|
3
|
+
|
4
|
+
<% if attributes.size > 0 -%>
|
5
|
+
attr_accessible <%= attributes.map{|attribute| attribute.reference? ? ":#{attribute.name}, :#{attribute.name}_id" : ":#{attribute.name}"} * ', ' %>
|
6
|
+
<% end -%>
|
7
|
+
<% attributes.select {|attr| attr.reference? }.each do |attribute| -%>
|
8
|
+
belongs_to :<%= attribute.name %>
|
9
|
+
<% end -%>
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'generators/humpyard'
|
2
|
+
require 'rails/generators/named_base'
|
3
|
+
require 'rails/generators/migration'
|
4
|
+
require 'rails/generators/active_model'
|
5
|
+
require 'active_record'
|
6
|
+
|
7
|
+
module Humpyard
|
8
|
+
module Generators
|
9
|
+
####
|
10
|
+
# == Element Generator
|
11
|
+
#
|
12
|
+
# rails humpyard:element ElementName [field:type field:type] [options]
|
13
|
+
#
|
14
|
+
# === Description
|
15
|
+
# The humpyard page generator creates a custom page that can
|
16
|
+
# be used inside your humpyard application.
|
17
|
+
#
|
18
|
+
# === Options
|
19
|
+
# <tt>[--skip-model]</tt>:: Don't generate a model or migration file.
|
20
|
+
# <tt>[--skip-migration]</tt>:: Dont generate migration file for model.
|
21
|
+
# <tt>[--skip-timestamps]</tt>:: Don't add timestamps to migration file.
|
22
|
+
# <tt>[--skip-views]</tt>:: Don't generate view files.
|
23
|
+
#
|
24
|
+
# === Runtime options
|
25
|
+
# <tt>-q, [--quiet]</tt>:: Supress status output
|
26
|
+
# <tt>-p, [--pretend]</tt>:: Run but do not make any changes
|
27
|
+
# <tt>-s, [--skip]</tt>:: Skip files that already exist
|
28
|
+
# <tt>-f, [--force]</tt>:: Overwrite files that already exist
|
29
|
+
#
|
30
|
+
# === Test framework options
|
31
|
+
# <tt>[--testunit]</tt>:: Use test/unit for test files.
|
32
|
+
# <tt>[--shoulda]</tt>:: Use shoulda for test files.
|
33
|
+
# <tt>[--rspec]</tt>:: Use RSpec for test files.
|
34
|
+
# <tt>[--skip-tests]</tt>:: Don't generate test files.
|
35
|
+
#
|
36
|
+
# === Examples
|
37
|
+
# rails generate humpyard:page SimpleText text:string
|
38
|
+
# rails generate humpyard:page another_thing content:text --skip-tests
|
39
|
+
#
|
40
|
+
#
|
41
|
+
class PageGenerator < Base
|
42
|
+
include Rails::Generators::Migration
|
43
|
+
|
44
|
+
argument :page_name, :type => :string, :required => true, :banner => 'PageName'
|
45
|
+
|
46
|
+
include Humpyard::Generators::ModelTemplate
|
47
|
+
|
48
|
+
def create_page # :nodoc:
|
49
|
+
template 'model.rb', "app/models/#{singular_name}.rb"
|
50
|
+
unless options.skip_tests?
|
51
|
+
case test_framework
|
52
|
+
when :rspec
|
53
|
+
template "tests/rspec/model.rb", "spec/models/#{singular_name}_spec.rb"
|
54
|
+
template 'fixtures.yml', "spec/fixtures/#{plural_name}.yml"
|
55
|
+
else
|
56
|
+
template "tests/#{test_framework}/model.rb", "test/unit/#{singular_name}_test.rb"
|
57
|
+
template 'fixtures.yml', "test/fixtures/#{plural_name}.yml"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
unless options.skip_migration?
|
62
|
+
migration_template 'migration.rb', "db/migrate/create_#{plural_name.gsub('/','_')}.rb"
|
63
|
+
end
|
64
|
+
unless options.skip_views?
|
65
|
+
template '_edit.html.haml', "app/views/humpyard/pages/#{plural_name}/_edit.html.haml"
|
66
|
+
template '_show.html.haml', "app/views/humpyard/pages/#{plural_name}/_show.html.haml"
|
67
|
+
end
|
68
|
+
|
69
|
+
unless options.skip_model?
|
70
|
+
create_model options
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
def model_name
|
76
|
+
"#{page_name.camelize}Page"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|