tb_core 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NWQwZjNkMTFiYmZhZGYxOTAzYjFjOGIxMmJmNzFjNjYxMzAyMzNhOA==
4
+ MmMxMjIyYjIwY2MyN2IyOWVmZTllNDU3Njk0ODE4MTU0OWQwZjIxMQ==
5
5
  data.tar.gz: !binary |-
6
- YTY2NzhiNzI3YTI2ZDQ3OWMxMWU2ZDgyMmE3ZWVhZWU2NDgwOTU5Mg==
6
+ MTdiMDBmNWFmNDI1ZWNmODA0MGFjNDQwNTI0M2I5NmZlMjhkZDQ5OA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDFkZjJhMWU2MzdlNzA4YzQyNDE0ZTljNzViZjI2ZDIwYzllNWM2YTA5NWM5
10
- ZjE1NTEwOGYyNTMyMDg2NDZkYmYyMTAzODcxYTU4MDUzMjJjMjc5NDRjNDMw
11
- ZDJmOWI3NmNjNzU5OGViNDViMjQ2MzY5ZDViN2I4YjE5OTk3NGE=
9
+ MTJiMzFlZTg3OWI5YzgzZTU0ZTQ4ZWExYTViOTM4MTM1ZGQ4YTExMmQxNzE2
10
+ OTU5MDBkNTRmNGQ4MjU3YTExZGIxMWU2ZDI3MmZiZDg1YWQzYzI5YmUzNmQx
11
+ ZDBlYTQ0OWE0MTM2YWY2MzhhOWQwZWI0ZGUyOWU0NGFjNDJjY2M=
12
12
  data.tar.gz: !binary |-
13
- ZWFkNWFjYzY3ODM1N2E0YjM3NDhjNTNlMDlmMDE3MWQ3Mzc5YTA4NmVhMWQ2
14
- NzM5NTJlMmYwZmE1MGFmMGQyMTYzZWVlMDU1OTkwNDY3ODEyZGU5ZWEwMmQ3
15
- YjgyYjgwNWM0OTI2NWJmMTM3ZTY0ZGNjNjQwOWY2MjMwNWZjMjc=
13
+ MmZkOTUyNzFkNzk2MGVkZDE0ODEzNTBlYmVhMDM5OTkyZmU3ZGQ5ZjU2M2Y0
14
+ YzI4OTc0Njk4ZGIyYjk0N2E0MGQ2ODhhZDRkMjI5NTcxZTZmZjdkMTUyMGZl
15
+ MzhiNTM3OTkwZTYwZTc4NjVkZjEyMWQxYWEyYzAxZTRmZTJiOTE=
data/README.md CHANGED
@@ -11,19 +11,31 @@ Installation/Usage
11
11
  gem 'tb_core'
12
12
 
13
13
  2. Run bundle install
14
-
15
- 3. Copy in database migrations to your new rails project
16
14
 
17
- bundle exec rake tb_core:install:migrations
18
- rake db:migrate
15
+ 3. Run the setup generator to copy in the base templates and migrations
16
+
17
+ `rails g spud:setup`
19
18
 
20
19
  4. run a rails server instance and point your browser to /admin
21
20
 
22
21
 
22
+ Setup Tasks
23
+ -----------
24
+
25
+ The `spud:setup` generator takes care of a few tasks for you. If you missed that step or would like to complete them manually, they are listed below:
26
+
27
+ 1. Your base `ApplicationController` should extend from `Spud::ApplicationController`.
28
+ 2. Your base `application.html.erb` should include a few special head tags.
29
+ 3. You should copy in the base migrations with `rake railties:install:migrations`.
30
+
23
31
  Adding Apps to the Dashboard
24
32
  ----------------------------
25
33
 
26
- Admin apps can be added via the `Spud::Core.config.admin_applications` array. We recommend you perform this action in either an initializer or within your `application.rb` file.
34
+ The fastest way to add an app to the dashboard is via the geneator. The generator will take care of creating a model as well as a set of controllers/views.
35
+
36
+ rails g spud:module Cars make:string model:string year:integer classic:boolean notes:text
37
+
38
+ Admin apps are added via the `Spud::Core.config.admin_applications` array. We recommend you perform this action in either an initializer or within your `application.rb` file.
27
39
 
28
40
  Spud::Core.config.admin_applications += [{
29
41
  :name => "Clients",
@@ -82,7 +94,7 @@ When building your own apps you may raise a `Spud::NotFoundError` at any time to
82
94
  def get_record
83
95
  @car = Car.where(:id => params[:id]).first
84
96
  if @car.blank?
85
- raise Spud::NotFoundError(:item => 'car')
97
+ raise Spud::NotFoundError.new(:item => 'car')
86
98
  end
87
99
  end
88
100
  end
@@ -81,7 +81,11 @@ private
81
81
  def handle_not_found(exception)
82
82
  @exception = exception
83
83
  @exception.request_url = request.original_url
84
- render :template => Spud::Core.not_found_template, :layout => nil, :formats => [:html], :status => 404
84
+ if request.xhr?
85
+ render :nothing => true, :status => 404
86
+ else
87
+ render :template => Spud::Core.not_found_template, :layout => nil, :formats => [:html], :status => 404
88
+ end
85
89
  end
86
90
 
87
91
  end
@@ -1,4 +1,16 @@
1
1
  module Spud::ApplicationHelper
2
+
3
+ def tb_page_title
4
+ if content_for?(:title)
5
+ title = content_for(:title) + ' : ' + Spud::Core.site_name
6
+ elsif @page_title
7
+ title = @page_title + ' : ' + Spud::Core.site_name
8
+ else
9
+ title = Spud::Core.site_name
10
+ end
11
+ return content_tag :title, title
12
+ end
13
+
2
14
  def current_site_name
3
15
  return Spud::Core.site_name if !Spud::Core.multisite_mode_enabled
4
16
  config = Spud::Core.site_config_for_host(request.host_with_port)
@@ -2,7 +2,7 @@
2
2
  <%= form_tag admin_password_resets_path do %>
3
3
  <div class="login-form-row">
4
4
  <%= label_tag :email %>
5
- <%= text_field_tag :email %>
5
+ <%= text_field_tag :email, params[:email], :placeholder => 'email', :autofocus => 'autofocus' %>
6
6
  </div>
7
7
  <div class="login-form-row">
8
8
  <%= submit_tag "Send Reset Instructions", :class => 'btn' %> or <%= link_to 'Cancel', admin_login_path %>
@@ -3,7 +3,7 @@
3
3
  <%= error_messages_for(f.object) %>
4
4
  <div class="field-group">
5
5
  <%= f.label :password %>
6
- <%= f.password_field :password %>
6
+ <%= f.password_field :password, :placeholder => 'password', :autofocus => 'autofocus' %>
7
7
  </div>
8
8
  <div class="field-group">
9
9
  <%= f.label :password_confirmation %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <div class="login-form-row">
6
6
  <%= f.label :login %>
7
- <%= f.text_field :login %>
7
+ <%= f.text_field :login, :autofocus => 'autofocus' %>
8
8
  </div>
9
9
  <div class="login-form-row">
10
10
  <%= f.label :password %>
@@ -1,9 +1,11 @@
1
+ <% @page_title = 'Password Reset' %>
2
+
1
3
  <h1>Password Reset</h1>
2
4
 
3
5
  <%= form_tag password_resets_path, :class => 'password-reset-form' do %>
4
6
  <div class="form-row">
5
7
  <%= label_tag :email %>
6
- <%= text_field_tag :email, params[:email], :placeholder => 'email' %>
8
+ <%= text_field_tag :email, params[:email], :placeholder => 'email', :autofocus => 'autofocus' %>
7
9
  </div>
8
10
  <div class="form-row form-row-actions">
9
11
  <%= submit_tag 'Submit', :class => 'btn btn-primary' %> or <%= link_to 'Cancel', login_path %>
@@ -1,10 +1,12 @@
1
+ <% @page_title = 'Password Reset' %>
2
+
1
3
  <div class="login-form">
2
4
  <h1>Password Reset</h1>
3
5
  <%= form_for @user, :url => password_reset_path(:id => @user.perishable_token), :html => {:class => 'password-reset-form'} do |f| %>
4
6
  <%= tb_form_errors(@user) %>
5
7
  <div class="form-row">
6
8
  <%= f.label :password %>
7
- <%= f.password_field :password, :placeholder => 'password' %>
9
+ <%= f.password_field :password, :placeholder => 'password', :autofocus => 'autofocus' %>
8
10
  </div>
9
11
  <div class="form-row">
10
12
  <%= f.label :password_confirmation, 'Confirm password' %>
@@ -1,10 +1,12 @@
1
+ <% @page_title = 'Login' %>
2
+
1
3
  <h1><%= Spud::Core.config.site_name %> Login</h1>
2
4
 
3
5
  <%= form_for @user_session, :url => login_path, :html => {:class => 'login-form'} do |f| %>
4
6
  <%= tb_form_errors(@user_session) %>
5
7
  <div class="form-row">
6
8
  <%= f.label :login %>
7
- <%= f.text_field :login, :placeholder => 'username' %>
9
+ <%= f.text_field :login, :placeholder => 'username', :autofocus => 'autofocus' %>
8
10
  </div>
9
11
  <div class="form-row">
10
12
  <%= f.label :password %>
@@ -16,7 +16,7 @@ class Spud::ModuleGenerator < ::Rails::Generators::Base
16
16
  template "views/admin/_form.html.erb", "app/views/admin/#{module_name_formatted}/_form.html.erb"
17
17
  template "views/frontend/index.html.erb", "app/views/#{module_name_formatted}/index.html.erb"
18
18
  template "views/frontend/show.html.erb", "app/views/#{module_name_formatted}/show.html.erb"
19
- environment("Spud::Core.config.admin_applications += [{:name => '#{module_name_formatted.humanize.titlecase}', :thumbnail => \"/assets/admin/portfolio.png\",:url => \"/admin/#{module_name_formatted}\"}]")
19
+ environment("Spud::Core.config.admin_applications += [{:name => '#{module_name_formatted.humanize.titlecase}', :thumbnail => \"/assets/admin/module_icon.png\",:url => \"/admin/#{module_name_formatted}\"}]")
20
20
  create_routes
21
21
  invoke "model", [module_name_formatted.singularize] + attributes
22
22
  end
@@ -0,0 +1,12 @@
1
+ class Spud::SetupGenerator < ::Rails::Generators::Base
2
+ desc 'Base setup for a new TB application'
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def setup
6
+ template "views/layouts/application.html.erb", "app/views/layouts/application.html.erb"
7
+ template "application_controller.rb", "app/controllers/application_controller.rb"
8
+ rake('railties:install:migrations')
9
+ rake('db:migrate')
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationController < Spud::ApplicationController
2
+ protect_from_forgery
3
+ end
@@ -17,7 +17,7 @@ private
17
17
  def load_<%=module_name_formatted.singularize%>
18
18
  @<%=module_name_formatted.singularize%> = <%=module_name_formatted.singularize.camelize%>.where(:id => params[:id]).first
19
19
  if @<%=module_name_formatted.singularize%>.blank?
20
- raise Spud::NotFoundError
20
+ raise Spud::NotFoundError.new(:item => '<%= module_name_formatted.singularize %>')
21
21
  return false
22
22
  end
23
23
  end
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <%%= tb_page_title() %>
5
+ <%%= stylesheet_link_tag "application", :media => "all" %>
6
+ <%%= javascript_include_tag "application" %>
7
+ <%%= csrf_meta_tags %>
8
+ <%%= yield :head %>
9
+ </head>
10
+ <body>
11
+
12
+ <%% if flash[:notice] %>
13
+ <p class="flash flash-notice"><%%= flash[:notice] %> <a href="#" class="flash-remove">X</a></p>
14
+ <%% elsif flash[:error] %>
15
+ <p class="flash flash-error"><%%= flash[:error] %> <a href="#" class="flash-remove">X</a></p>
16
+ <%% end %>
17
+
18
+ <%%= content_for?(:body) ? yield(:body) : yield %>
19
+
20
+ </body>
21
+ </html>
@@ -1,5 +1,5 @@
1
1
  module Spud
2
2
  module Core
3
- VERSION = "1.1.6"
3
+ VERSION = "1.1.7"
4
4
  end
5
5
  end