comfy_blog 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +11 -0
- data/LICENSE +20 -0
- data/README.md +23 -0
- data/Rakefile +21 -0
- data/VERSION +1 -0
- data/app/assets/images/rails.png +0 -0
- data/app/assets/javascripts/application.js +8 -0
- data/app/assets/stylesheets/comfy_blog/admin.css +57 -0
- data/app/assets/stylesheets/comfy_blog/application.css +73 -0
- data/app/assets/stylesheets/comfy_blog/reset.css +1 -0
- data/app/controllers/application_controller.rb +5 -0
- data/app/controllers/blog/admin/base_controller.rb +3 -0
- data/app/controllers/blog/admin/comments_controller.rb +34 -0
- data/app/controllers/blog/admin/posts_controller.rb +57 -0
- data/app/controllers/blog/posts_controller.rb +33 -0
- data/app/helpers/blog/application_helper.rb +16 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/blog/comment.rb +21 -0
- data/app/models/blog/post.rb +81 -0
- data/app/models/blog/tag.rb +25 -0
- data/app/models/blog/tagging.rb +22 -0
- data/app/views/blog/admin/_html_head.html.erb +1 -0
- data/app/views/blog/admin/_navigation.html.erb +1 -0
- data/app/views/blog/admin/comments/_comment.html.erb +22 -0
- data/app/views/blog/admin/comments/destroy.js.erb +3 -0
- data/app/views/blog/admin/comments/index.html.erb +10 -0
- data/app/views/blog/admin/comments/publish.js.erb +1 -0
- data/app/views/blog/admin/posts/_form.html.erb +24 -0
- data/app/views/blog/admin/posts/_post.html.erb +21 -0
- data/app/views/blog/admin/posts/edit.html.erb +5 -0
- data/app/views/blog/admin/posts/index.html.erb +9 -0
- data/app/views/blog/admin/posts/new.html.erb +5 -0
- data/app/views/blog/posts/_post.html.erb +18 -0
- data/app/views/blog/posts/index.html.erb +5 -0
- data/app/views/blog/posts/show.html.erb +1 -0
- data/app/views/layouts/application.html.erb +17 -0
- data/comfy_blog.gemspec +125 -0
- data/config.ru +4 -0
- data/config/application.rb +48 -0
- data/config/boot.rb +6 -0
- data/config/database.yml +25 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +33 -0
- data/config/environments/production.rb +51 -0
- data/config/environments/test.rb +42 -0
- data/config/initializers/comfy_blog.rb +18 -0
- data/config/initializers/secret_token.rb +3 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +29 -0
- data/db/migrate/01_create_comfy_blog.rb +55 -0
- data/db/schema.rb +63 -0
- data/db/seeds.rb +7 -0
- data/lib/comfy_blog.rb +26 -0
- data/lib/comfy_blog/configuration.rb +33 -0
- data/lib/comfy_blog/core_ext/string.rb +8 -0
- data/lib/comfy_blog/engine.rb +20 -0
- data/lib/comfy_blog/form_builder.rb +50 -0
- data/lib/generators/README +10 -0
- data/lib/generators/blog_generator.rb +31 -0
- data/script/rails +6 -0
- data/test/fixtures/.gitkeep +0 -0
- data/test/fixtures/blog/comments.yml +6 -0
- data/test/fixtures/blog/posts.yml +8 -0
- data/test/fixtures/blog/taggings.yml +7 -0
- data/test/fixtures/blog/tags.yml +9 -0
- data/test/functional/.gitkeep +0 -0
- data/test/functional/blog/admin/comments_controller_test.rb +38 -0
- data/test/functional/blog/admin/posts_controller_test.rb +100 -0
- data/test/functional/blog/posts_controller_test.rb +93 -0
- data/test/test_helper.rb +40 -0
- data/test/unit/.gitkeep +0 -0
- data/test/unit/comment_test.rb +34 -0
- data/test/unit/configuration_test.rb +19 -0
- data/test/unit/post_test.rb +121 -0
- data/test/unit/tag_test.rb +44 -0
- data/test/unit/tagging_test.rb +30 -0
- metadata +172 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
|
11
|
+
# Disable Rails's static asset server (Apache or nginx will already do this)
|
12
|
+
config.serve_static_assets = false
|
13
|
+
|
14
|
+
# Compress JavaScripts and CSS
|
15
|
+
config.assets.compress = true
|
16
|
+
|
17
|
+
# Specifies the header that your server uses for sending files
|
18
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
19
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
20
|
+
|
21
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
22
|
+
# config.force_ssl = true
|
23
|
+
|
24
|
+
# See everything in the log (default is :info)
|
25
|
+
# config.log_level = :debug
|
26
|
+
|
27
|
+
# Use a different logger for distributed setups
|
28
|
+
# config.logger = SyslogLogger.new
|
29
|
+
|
30
|
+
# Use a different cache store in production
|
31
|
+
# config.cache_store = :mem_cache_store
|
32
|
+
|
33
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server
|
34
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
35
|
+
|
36
|
+
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
|
37
|
+
# config.assets.precompile += %w( search.js )
|
38
|
+
|
39
|
+
# Disable delivery errors, bad email addresses will be ignored
|
40
|
+
# config.action_mailer.raise_delivery_errors = false
|
41
|
+
|
42
|
+
# Enable threaded mode
|
43
|
+
# config.threadsafe!
|
44
|
+
|
45
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
46
|
+
# the I18n.default_locale when a translation can not be found)
|
47
|
+
config.i18n.fallbacks = true
|
48
|
+
|
49
|
+
# Send deprecation notices to registered listeners
|
50
|
+
config.active_support.deprecation = :notify
|
51
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
defined?(ComfyBlog::Application) && ComfyBlog::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Configure static asset server for tests with Cache-Control for performance
|
11
|
+
config.serve_static_assets = true
|
12
|
+
config.static_cache_control = "public, max-age=3600"
|
13
|
+
|
14
|
+
# Log error messages when you accidentally call methods on nil
|
15
|
+
config.whiny_nils = true
|
16
|
+
|
17
|
+
# Show full error reports and disable caching
|
18
|
+
config.consider_all_requests_local = true
|
19
|
+
config.action_controller.perform_caching = false
|
20
|
+
|
21
|
+
# Raise exceptions instead of rendering exception templates
|
22
|
+
config.action_dispatch.show_exceptions = false
|
23
|
+
|
24
|
+
# Disable request forgery protection in test environment
|
25
|
+
config.action_controller.allow_forgery_protection = false
|
26
|
+
|
27
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
28
|
+
# The :test delivery method accumulates sent emails in the
|
29
|
+
# ActionMailer::Base.deliveries array.
|
30
|
+
config.action_mailer.delivery_method = :test
|
31
|
+
|
32
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
33
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
34
|
+
# like if you have constraints or database-specific column types
|
35
|
+
# config.active_record.schema_format = :sql
|
36
|
+
|
37
|
+
# Print deprecation notices to the stderr
|
38
|
+
config.active_support.deprecation = :stderr
|
39
|
+
|
40
|
+
# Allow pass debug_assets=true as a query parameter to load pages with unpackaged assets
|
41
|
+
config.assets.allow_debugging = true
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
ComfyBlog.configure do |config|
|
2
|
+
|
3
|
+
# set the cms admin path if you have changed it for CMS
|
4
|
+
# config.admin_route_prefix = 'admin'
|
5
|
+
|
6
|
+
# Controller that should be used for admin area
|
7
|
+
# config.admin_controller = 'ApplicationController'
|
8
|
+
|
9
|
+
# Form builder
|
10
|
+
# config.form_builder = 'ComfyBlog::FormBuilder'
|
11
|
+
|
12
|
+
# Layout used for public posts/comments
|
13
|
+
# config.public_layout = 'application'
|
14
|
+
|
15
|
+
# Number of posts per page. Default is 10
|
16
|
+
# config.posts_per_page = 10
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
#
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Disable root element in JSON by default.
|
12
|
+
ActiveSupport.on_load(:active_record) do
|
13
|
+
self.include_root_in_json = false
|
14
|
+
end
|
data/config/routes.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
scope :module => :blog do
|
4
|
+
namespace :admin, :path => ComfyBlog.config.admin_route_prefix do
|
5
|
+
resources :posts, :except => [:show] do
|
6
|
+
resources :comments, :only => [:index]
|
7
|
+
end
|
8
|
+
resources :comments, :only => [:index, :destroy] do
|
9
|
+
put :publish, :on => :member
|
10
|
+
end
|
11
|
+
resources :tags, :except => [:show]
|
12
|
+
end unless ComfyBlog.config.admin_route_prefix.blank?
|
13
|
+
end
|
14
|
+
|
15
|
+
scope ComfyBlog.config.public_route_prefix, :module => :blog do
|
16
|
+
get '' => 'posts#index', :as => :blog_posts
|
17
|
+
get 'tag/:tag' => 'posts#index', :as => :tagged_blog_posts
|
18
|
+
get 'category/:category' => 'posts#index', :as => :categorized_blog_posts
|
19
|
+
|
20
|
+
with_options :constraints => { :year => /\d{4}/, :month => /\d{1,2}/ } do |o|
|
21
|
+
o.get ':year' => 'posts#index', :as => :year_blog_posts
|
22
|
+
o.get ':year/:month' => 'posts#index', :as => :month_blog_posts
|
23
|
+
o.get ':year/:month/:slug' => 'posts#show', :as => :dated_blog_post
|
24
|
+
end
|
25
|
+
|
26
|
+
get ':id' => 'posts#show', :as => :blog_post
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class CreateComfyBlog < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def self.up
|
4
|
+
create_table :blog_posts do |t|
|
5
|
+
t.string :title, :null => false
|
6
|
+
t.string :slug, :null => false
|
7
|
+
t.text :content
|
8
|
+
t.string :excerpt, :limit => 1024
|
9
|
+
t.string :author
|
10
|
+
t.integer :year, :null => false, :limit => 4
|
11
|
+
t.integer :month, :null => false, :limit => 2
|
12
|
+
t.boolean :is_published, :null => false, :default => true
|
13
|
+
t.timestamps
|
14
|
+
end
|
15
|
+
add_index :blog_posts, [:is_published, :year, :month, :slug],
|
16
|
+
:name => 'index_blog_posts_on_published_year_month_slug'
|
17
|
+
add_index :blog_posts, [:is_published, :created_at]
|
18
|
+
add_index :blog_posts, :created_at
|
19
|
+
|
20
|
+
create_table :blog_comments do |t|
|
21
|
+
t.integer :post_id, :null => false
|
22
|
+
t.string :author, :null => false
|
23
|
+
t.string :email, :null => false
|
24
|
+
t.text :content
|
25
|
+
t.boolean :is_published, :null => false, :default => false
|
26
|
+
t.timestamps
|
27
|
+
end
|
28
|
+
add_index :blog_comments, [:post_id, :created_at]
|
29
|
+
add_index :blog_comments, [:post_id, :is_published, :created_at],
|
30
|
+
:name => 'index_blog_comments_on_post_published_created'
|
31
|
+
|
32
|
+
create_table :blog_tags do |t|
|
33
|
+
t.string :name, :null => false
|
34
|
+
t.boolean :is_category, :null => false, :default => false
|
35
|
+
t.integer :taggings_count, :null => false, :default => 0
|
36
|
+
end
|
37
|
+
add_index :blog_tags, [:name, :taggings_count], :unique => true
|
38
|
+
add_index :blog_tags, :taggings_count
|
39
|
+
|
40
|
+
create_table :blog_taggings do |t|
|
41
|
+
t.integer :post_id, :null => false
|
42
|
+
t.integer :tag_id, :null => false
|
43
|
+
t.datetime :created_at
|
44
|
+
end
|
45
|
+
add_index :blog_taggings, [:post_id, :tag_id, :created_at], :unique => true,
|
46
|
+
:name => 'index_blog_taggings_on_post_tag_created'
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.down
|
50
|
+
drop_table :sofa_blog_posts
|
51
|
+
drop_table :sofa_blog_comments
|
52
|
+
drop_table :sofa_blog_tags
|
53
|
+
drop_table :sofa_blog_taggings
|
54
|
+
end
|
55
|
+
end
|
data/db/schema.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# This file is auto-generated from the current state of the database. Instead
|
3
|
+
# of editing this file, please use the migrations feature of Active Record to
|
4
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
5
|
+
#
|
6
|
+
# Note that this schema.rb definition is the authoritative source for your
|
7
|
+
# database schema. If you need to create the application database on another
|
8
|
+
# system, you should be using db:schema:load, not running all the migrations
|
9
|
+
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
10
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
11
|
+
#
|
12
|
+
# It's strongly recommended to check this file into your version control system.
|
13
|
+
|
14
|
+
ActiveRecord::Schema.define(:version => 1) do
|
15
|
+
|
16
|
+
create_table "blog_comments", :force => true do |t|
|
17
|
+
t.integer "post_id", :null => false
|
18
|
+
t.string "author", :null => false
|
19
|
+
t.string "email", :null => false
|
20
|
+
t.text "content"
|
21
|
+
t.boolean "is_published", :default => false, :null => false
|
22
|
+
t.datetime "created_at"
|
23
|
+
t.datetime "updated_at"
|
24
|
+
end
|
25
|
+
|
26
|
+
add_index "blog_comments", ["post_id", "created_at"], :name => "index_blog_comments_on_post_id_and_created_at"
|
27
|
+
add_index "blog_comments", ["post_id", "is_published", "created_at"], :name => "index_blog_comments_on_post_published_created"
|
28
|
+
|
29
|
+
create_table "blog_posts", :force => true do |t|
|
30
|
+
t.string "title", :null => false
|
31
|
+
t.string "slug", :null => false
|
32
|
+
t.text "content"
|
33
|
+
t.string "excerpt", :limit => 1024
|
34
|
+
t.string "author"
|
35
|
+
t.integer "year", :limit => 4, :null => false
|
36
|
+
t.integer "month", :limit => 2, :null => false
|
37
|
+
t.boolean "is_published", :default => false, :null => false
|
38
|
+
t.datetime "created_at"
|
39
|
+
t.datetime "updated_at"
|
40
|
+
end
|
41
|
+
|
42
|
+
add_index "blog_posts", ["created_at"], :name => "index_blog_posts_on_created_at"
|
43
|
+
add_index "blog_posts", ["is_published", "created_at"], :name => "index_blog_posts_on_is_published_and_created_at"
|
44
|
+
add_index "blog_posts", ["is_published", "year", "month", "slug"], :name => "index_blog_posts_on_published_year_month_slug"
|
45
|
+
|
46
|
+
create_table "blog_taggings", :force => true do |t|
|
47
|
+
t.integer "post_id", :null => false
|
48
|
+
t.integer "tag_id", :null => false
|
49
|
+
t.datetime "created_at"
|
50
|
+
end
|
51
|
+
|
52
|
+
add_index "blog_taggings", ["post_id", "tag_id", "created_at"], :name => "index_blog_taggings_on_post_tag_created", :unique => true
|
53
|
+
|
54
|
+
create_table "blog_tags", :force => true do |t|
|
55
|
+
t.string "name", :null => false
|
56
|
+
t.boolean "is_category", :default => false, :null => false
|
57
|
+
t.integer "taggings_count", :default => 0, :null => false
|
58
|
+
end
|
59
|
+
|
60
|
+
add_index "blog_tags", ["name", "taggings_count"], :name => "index_blog_tags_on_name_and_taggings_count", :unique => true
|
61
|
+
add_index "blog_tags", ["taggings_count"], :name => "index_blog_tags_on_taggings_count"
|
62
|
+
|
63
|
+
end
|
data/db/seeds.rb
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
3
|
+
#
|
4
|
+
# Examples:
|
5
|
+
#
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
data/lib/comfy_blog.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Loading engine only if this is not a standalone installation
|
2
|
+
unless defined? ComfyBlog::Application
|
3
|
+
require File.expand_path('sofa_blog/engine', File.dirname(__FILE__))
|
4
|
+
end
|
5
|
+
|
6
|
+
[ 'comfy_blog/core_ext/string',
|
7
|
+
'comfy_blog/configuration',
|
8
|
+
'comfy_blog/form_builder'
|
9
|
+
].each do |path|
|
10
|
+
require File.expand_path(path, File.dirname(__FILE__))
|
11
|
+
end
|
12
|
+
|
13
|
+
module ComfyBlog
|
14
|
+
class << self
|
15
|
+
|
16
|
+
def configure
|
17
|
+
yield configuration
|
18
|
+
end
|
19
|
+
|
20
|
+
def configuration
|
21
|
+
@configuration ||= Configuration.new
|
22
|
+
end
|
23
|
+
alias :config :configuration
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module ComfyBlog
|
2
|
+
class Configuration
|
3
|
+
# Default url to access admin area is http://yourhost/cms-admin/
|
4
|
+
# You can change 'cms-admin' to 'admin', for example.
|
5
|
+
attr_accessor :admin_route_prefix
|
6
|
+
|
7
|
+
# Prefix of the url where blog posts are served from. If you wish to
|
8
|
+
# serve posts from /blog change this setting to 'blog'. Default is blank.
|
9
|
+
attr_accessor :public_route_prefix
|
10
|
+
|
11
|
+
# Controller that should be used for admin area
|
12
|
+
attr_accessor :admin_controller
|
13
|
+
|
14
|
+
# Form builder
|
15
|
+
attr_accessor :form_builder
|
16
|
+
|
17
|
+
# Layout used for public posts/comments
|
18
|
+
attr_accessor :public_layout
|
19
|
+
|
20
|
+
# Number of posts per page. Default is 10
|
21
|
+
attr_accessor :posts_per_page
|
22
|
+
|
23
|
+
# Configuration defaults
|
24
|
+
def initialize
|
25
|
+
@admin_route_prefix = 'admin'
|
26
|
+
@public_route_prefix = ''
|
27
|
+
@admin_controller = 'ApplicationController'
|
28
|
+
@form_builder = 'ComfyBlog::FormBuilder'
|
29
|
+
@public_layout = 'application'
|
30
|
+
@posts_per_page = 10
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'sofa_blog'
|
2
|
+
require 'rails'
|
3
|
+
|
4
|
+
module SofaBlog
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
initializer 'sofa_blog.configuration' do |app|
|
7
|
+
if defined?(ComfortableMexicanSofa)
|
8
|
+
# Applying configuraion
|
9
|
+
SofaBlog.configure do |conf|
|
10
|
+
conf.admin_route_prefix = ComfortableMexicanSofa.config.admin_route_prefix
|
11
|
+
conf.admin_controller = 'CmsAdmin::BaseController'
|
12
|
+
conf.form_builder = 'ComfortableMexicanSofa::FormBuilder'
|
13
|
+
end
|
14
|
+
# Adding view hooks
|
15
|
+
ComfortableMexicanSofa::ViewHooks.add(:navigation, '/sofa_blog/admin/navigation')
|
16
|
+
ComfortableMexicanSofa::ViewHooks.add(:html_head, '/sofa_blog/admin/html_head')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class ComfyBlog::FormBuilder < ActionView::Helpers::FormBuilder
|
2
|
+
|
3
|
+
helpers = field_helpers -
|
4
|
+
%w(hidden_field fields_for) +
|
5
|
+
%w(select)
|
6
|
+
|
7
|
+
helpers.each do |name|
|
8
|
+
class_eval %Q^
|
9
|
+
def #{name}(field, *args)
|
10
|
+
options = args.extract_options!
|
11
|
+
args << options
|
12
|
+
return super if options.delete(:disable_builder)
|
13
|
+
default_field('#{name}', field, options){ super }
|
14
|
+
end
|
15
|
+
^
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_field(type, field, options = {}, &block)
|
19
|
+
errors = if object.respond_to?(:errors) && object.errors[field].present?
|
20
|
+
"<div class='errors'>#{[object.errors[field]].flatten.first}</div>"
|
21
|
+
end
|
22
|
+
if desc = options.delete(:desc)
|
23
|
+
desc = "<div class='desc'>#{desc}</div>"
|
24
|
+
end
|
25
|
+
%(
|
26
|
+
<div class='form_element #{type}_element #{'errors' if errors}'>
|
27
|
+
<div class='label'>#{label_for(field, options)}</div>
|
28
|
+
<div class='value'>#{yield}</div>
|
29
|
+
#{desc}
|
30
|
+
#{errors}
|
31
|
+
</div>
|
32
|
+
).html_safe
|
33
|
+
end
|
34
|
+
|
35
|
+
def label_for(field, options)
|
36
|
+
label = options.delete(:label) || field.to_s.titleize.capitalize
|
37
|
+
"<label for=\"#{object_name}_#{field}\">#{label}</label>".html_safe
|
38
|
+
end
|
39
|
+
|
40
|
+
def simple_field(label = nil, content = nil, options = {}, &block)
|
41
|
+
content ||= @template.capture(&block) if block_given?
|
42
|
+
%(
|
43
|
+
<div class='form_element #{options.delete(:class)}'>
|
44
|
+
<div class='label'>#{label}</div>
|
45
|
+
<div class='value'>#{content}</div>
|
46
|
+
</div>
|
47
|
+
).html_safe
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|