tkh_content 0.0.3.1 → 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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
 
4
4
 
5
+ ## 0.1
6
+
7
+ * Reverted pages show route to that one of a normal resource
8
+ * Added a belongs_to author association with migration and everything
9
+ * Added a migration to add a parent_id page attribute in preparation to menu building
10
+ * Improved pages index view with more info
11
+ * Removed erroneous instruction from README file
12
+
13
+
5
14
  ## 0.0.3.1
6
15
 
7
16
  * Debugged the special page show route. It has to come last in order not to conflict with other routes
data/README.md CHANGED
@@ -26,21 +26,34 @@ Then execute:
26
26
 
27
27
  $ bundle
28
28
 
29
- Import migration
29
+ Import migrations and needed files
30
30
 
31
31
  $ rake tkh_content:install
32
32
 
33
- Run the migration
33
+ Run the migrations
34
34
 
35
35
  $ rake db:migrate
36
36
 
37
- Add these 3 lines to the bottom of your routes file, just before the final end statement
37
+ And then of course restart your server!
38
38
 
39
- scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
40
- resources :pages, only: :show, path: ''
41
- end
39
+ $ rails s
42
40
 
43
- And then of course restart your server!
41
+
42
+ ## Upgrading
43
+
44
+ Update the gem:
45
+
46
+ $ bundle update tkh_content
47
+
48
+ Update files, migrations, etc. This is only needed with a new minor version number ( second level from left )
49
+
50
+ $ rake tkh_content:update
51
+
52
+ Run migrations if there are new ones
53
+
54
+ $ rake db:migrate
55
+
56
+ Start your server!
44
57
 
45
58
  $ rails s
46
59
 
@@ -25,6 +25,7 @@ class PagesController < ApplicationController
25
25
 
26
26
  def create
27
27
  @page = Page.new(params[:page])
28
+ @page.author_id = current_user.id
28
29
  if @page.save
29
30
  redirect_to @page, notice: t('pages.create.notice')
30
31
  else
@@ -35,7 +36,7 @@ class PagesController < ApplicationController
35
36
  def update
36
37
  @page = Page.find(params[:id])
37
38
  if @page.update_attributes(params[:page])
38
- redirect_to url_for(action: :show, id: @page), notice: t('pages.update.notice')
39
+ redirect_to @page, notice: t('pages.update.notice')
39
40
  else
40
41
  render action: "edit", warning: t('pages.update.warning'), layout: 'admin'
41
42
  end
data/app/models/page.rb CHANGED
@@ -5,11 +5,14 @@ end
5
5
 
6
6
  class Page < ActiveRecord::Base
7
7
 
8
+ belongs_to :author, class_name: 'User', foreign_key: 'author_id'
9
+
8
10
  attr_accessible :body, :description, :title, :blog_post, :for_blog
9
11
 
10
12
  validates_presence_of :title
11
13
  validates_presence_of :description
12
14
  validates_presence_of :body
15
+ validates_presence_of :author_id
13
16
 
14
17
  translates :title, :description, :body
15
18
 
@@ -5,7 +5,9 @@
5
5
  <tr>
6
6
  <th><%= t 'activerecord.attributes.pages.title' %></th>
7
7
  <th><%= t 'activerecord.attributes.pages.description' %></th>
8
+ <th><%= t 'pages.author'.capitalize %></th>
8
9
  <th><%= t 'activerecord.attributes.pages.for_blog' %>?</th>
10
+ <th><%= t 'pages.published'.capitalize %></th>
9
11
  <th>Actions</th>
10
12
  </tr>
11
13
  </thead>
@@ -13,9 +15,11 @@
13
15
  <tbody>
14
16
  <% @pages.each do |page| %>
15
17
  <tr>
16
- <td><%= link_to page.title, page.to_param %></td>
18
+ <td><%= link_to page.title, page %></td>
17
19
  <td><%= truncate page.description, length: 55, separator: ' ...' %></td>
20
+ <td><%= page.author.name %></td>
18
21
  <td><%= page.for_blog? ? '✓' : 'X' %></td>
22
+ <td><%= page.published_at ? '✓ ' + l( page.published_at.to_date, format: :long) : 'X' %></td>
19
23
  <td><%= link_to t('edit'), edit_page_path(page), class: 'btn btn-mini' %>
20
24
  <%= link_to t('delete'), page, method: :delete, data: { confirm: t('are_you_sure') }, class: 'btn btn-mini btn-danger' %></td>
21
25
  </tr>
data/config/routes.rb CHANGED
@@ -1,13 +1,5 @@
1
1
  Rails.application.routes.draw do
2
2
  scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
3
- resources :pages, except: :show
3
+ resources :pages
4
4
  end
5
- end
6
-
7
-
8
- # this is a bit funky
9
- # These 3 lines must be copied by hand to the bottom of the routes file and un-commented
10
-
11
- # scope "(:locale)", locale: /#{I18n.available_locales.join("|")}/ do
12
- # resources :pages, only: :show, path: ''
13
- # end
5
+ end
@@ -21,7 +21,10 @@ en:
21
21
  sections: 'sections'
22
22
 
23
23
  pages:
24
+ author: 'author'
24
25
  create_new: 'create new page'
26
+ published: 'published?'
27
+
25
28
  create:
26
29
  notice: 'The page was successfully created.'
27
30
  warning: 'There was a problem saving the page'
@@ -8,15 +8,18 @@ es:
8
8
  sections: 'secciones'
9
9
 
10
10
  activerecord:
11
- attributes:
12
- pages:
13
- title: "título"
14
- description: "descripción"
15
- body: "parte principal"
16
- para el blog: 'contraseña'
11
+ attributes:
12
+ pages:
13
+ title: "título"
14
+ description: "descripción"
15
+ body: "parte principal"
16
+ para el blog: 'contraseña'
17
17
 
18
18
  pages:
19
+ author: 'autor'
19
20
  create_new: 'crear una nueva página'
21
+ published: '¿publicado?'
22
+
20
23
  create:
21
24
  notice: 'La página se ha creado correctamente'
22
25
  warning: 'Hubo un problema al guardar la página'
@@ -187,15 +187,18 @@ fr:
187
187
  sections: 'sections'
188
188
 
189
189
  activerecord:
190
- attributes:
191
- pages:
192
- title: "titre"
193
- description: "description"
194
- body: "texte principal"
195
- para el blog: 'pour le blog'
190
+ attributes:
191
+ pages:
192
+ title: "titre"
193
+ description: "description"
194
+ body: "texte principal"
195
+ para el blog: 'pour le blog'
196
196
 
197
197
  pages:
198
+ author: 'auteur'
198
199
  create_new: 'créer une nouvelle page'
200
+ published: 'publiée ?'
201
+
199
202
  create:
200
203
  notice: 'La page a été créée.'
201
204
  warning: "Il y'a eu un problem et la page n'a pas été sauvegardée"
@@ -2,10 +2,10 @@ require 'rails/generators/migration'
2
2
 
3
3
  module TkhContent
4
4
  module Generators
5
- class CreateMigrationGenerator < ::Rails::Generators::Base
5
+ class CreateOrUpdateMigrationsGenerator < ::Rails::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
  source_root File.expand_path('../templates', __FILE__)
8
- desc "add the migration"
8
+ desc "create or update page migrations"
9
9
  def self.next_migration_number(path)
10
10
  unless @prev_migration_nr
11
11
  @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
@@ -16,8 +16,10 @@ module TkhContent
16
16
  end
17
17
 
18
18
  def copy_migrations
19
- puts 'creating user migration'
19
+ puts 'creating or updating page migrations'
20
20
  migration_template "create_pages.rb", "db/migrate/create_pages.rb"
21
+ migration_template "add_author_to_pages.rb", "db/migrate/add_author_to_pages.rb"
22
+ migration_template "add_parent_id_to_pages.rb", "db/migrate/add_parent_id_to_pages.rb"
21
23
  end
22
24
 
23
25
  end
@@ -0,0 +1,6 @@
1
+ class AddAuthorToPages < ActiveRecord::Migration
2
+ def change
3
+ add_column :pages, :author_id, :integer
4
+ add_index :pages, :author_id
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AddParentIdToPages < ActiveRecord::Migration
2
+ def change
3
+ add_column :pages, :parent_id, :integer
4
+ add_index :pages, :parent_id
5
+ end
6
+ end
@@ -1,14 +1,14 @@
1
1
  namespace :tkh_content do
2
2
  desc "Create migrations, locale, and other files"
3
3
  task :install do
4
- system 'rails g tkh_content:create_migration'
4
+ system 'rails g tkh_content:create_or_update_migrations'
5
5
  system 'rails g tkh_content:create_or_update_locales -f'
6
6
  system 'rails g tkh_content:create_or_update_files -f'
7
7
  end
8
8
 
9
9
  desc "Update files. Skip existing migrations and blog layout. Force overwrite locales"
10
10
  task :update do
11
- system 'rails g tkh_content:create_migration -s'
11
+ system 'rails g tkh_content:create_or_update_migrations -s'
12
12
  system 'rails g tkh_content:create_or_update_locales -f'
13
13
  system 'rails g tkh_content:create_or_update_files -s'
14
14
  end
@@ -1,3 +1,3 @@
1
1
  module TkhContent
2
- VERSION = "0.0.3.1"
2
+ VERSION = "0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tkh_content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3.1
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-04 00:00:00.000000000 Z
12
+ date: 2012-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -107,14 +107,16 @@ files:
107
107
  - app/views/pages/show.html.erb
108
108
  - app/views/shared/_admin_sidebar.html.erb
109
109
  - config/routes.rb
110
- - lib/generators/tkh_content/create_migration/create_migration_generator.rb
111
- - lib/generators/tkh_content/create_migration/templates/create_pages.rb
112
110
  - lib/generators/tkh_content/create_or_update_files/create_or_update_files_generator.rb
113
111
  - lib/generators/tkh_content/create_or_update_files/templates/blog.html.erb
114
112
  - lib/generators/tkh_content/create_or_update_locales/create_or_update_locales_generator.rb
115
113
  - lib/generators/tkh_content/create_or_update_locales/templates/en.yml
116
114
  - lib/generators/tkh_content/create_or_update_locales/templates/es.yml
117
115
  - lib/generators/tkh_content/create_or_update_locales/templates/fr.yml
116
+ - lib/generators/tkh_content/create_or_update_migrations/create_or_update_migrations_generator.rb
117
+ - lib/generators/tkh_content/create_or_update_migrations/templates/add_author_to_pages.rb
118
+ - lib/generators/tkh_content/create_or_update_migrations/templates/add_parent_id_to_pages.rb
119
+ - lib/generators/tkh_content/create_or_update_migrations/templates/create_pages.rb
118
120
  - lib/tasks/tkh_content_tasks.rake
119
121
  - lib/tkh_content/version.rb
120
122
  - lib/tkh_content.rb
@@ -166,7 +168,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
168
  version: '0'
167
169
  segments:
168
170
  - 0
169
- hash: -675212526871244421
171
+ hash: -3666386950165349341
170
172
  required_rubygems_version: !ruby/object:Gem::Requirement
171
173
  none: false
172
174
  requirements:
@@ -175,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
177
  version: '0'
176
178
  segments:
177
179
  - 0
178
- hash: -675212526871244421
180
+ hash: -3666386950165349341
179
181
  requirements: []
180
182
  rubyforge_project:
181
183
  rubygems_version: 1.8.23