merrycms 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,8 +9,9 @@ module Admin
9
9
  end
10
10
 
11
11
  def index
12
- @search = Page.search(params[:search])
13
- @pages = @search.order(:title).page(params[:page]).per(5)
12
+ @search = Page.includes(:category).search(params[:search])
13
+ @pages = @search.order("created_at desc").page(params[:page])
14
+ puts @pages # hack for kaminari
14
15
  end
15
16
 
16
17
  def new
@@ -15,12 +15,12 @@ module Admin
15
15
  end
16
16
 
17
17
  def all
18
- @search = Translation.not_pending.search(params[:search])
18
+ @search = Translation.not_pending.order("created_at desc").search(params[:search])
19
19
  @translations = @search.where(:locale => params[:language]).page(params[:page]).per(10)
20
20
  end
21
21
 
22
22
  def pending
23
- @search = Translation.pending.search(params[:search])
23
+ @search = Translation.pending.order("created_at desc").search(params[:search])
24
24
  @translations = @search.where(:locale => params[:language]).page(params[:page]).per(10)
25
25
  end
26
26
 
@@ -43,7 +43,7 @@ module Admin
43
43
  @translation = Translation.find(params[:id])
44
44
  @translation.destroy
45
45
  respond_with(@translation) do |format|
46
- format.html { redirect_to new_admin_translation_path(:type => params[:type], :language => params[:language]) }
46
+ format.html { redirect_to admin_translations_path(:language => params[:language]) }
47
47
  format.js
48
48
  end
49
49
  end
data/app/models/page.rb CHANGED
@@ -28,10 +28,8 @@ class Page < ActiveRecord::Base
28
28
  event :unarchive do
29
29
  transitions :to => :draft, :from => :archived, :on_transition => :unset_archived_at
30
30
  end
31
-
32
31
  end
33
32
 
34
-
35
33
  def available_events
36
34
  Page.state_machines[:default].events_for(self.state.to_sym)
37
35
  end
@@ -4,6 +4,8 @@
4
4
 
5
5
  <%= render 'search' %>
6
6
 
7
+ <%= paginate @pages %>
8
+
7
9
  <table>
8
10
  <tr>
9
11
  <th><%= t('activerecord.attributes.page.title') %></th>
@@ -29,4 +31,3 @@
29
31
  <% end %>
30
32
  </table>
31
33
 
32
- <%= paginate @pages %>
@@ -17,7 +17,7 @@
17
17
  <%= hidden_field_tag "translations[#{index}][destroy]", false, :class => 'translation-destroy' %>
18
18
  <%= text_area_tag "translations[#{index}][value]", translation[:value] %>
19
19
  </td>
20
- <td class="actions"><%= link_to t('translations.delete'), admin_translation_path(translation[:id], :type => params[:type], :language => params[:language]), :method => :delete, :class => :delete, :remote => true %></td>
20
+ <td class="actions"><%= link_to t('translations.delete'), admin_translation_path(translation[:id], :language => params[:language]), :method => :delete, :class => :delete, :remote => true %></td>
21
21
  </tr>
22
22
  <% end %>
23
23
  <tr>
@@ -10,7 +10,7 @@
10
10
  <ul class='pending'>
11
11
  <% @pending_translations.each do |translation| %>
12
12
  <li>
13
- <%= link_to t("translations.locales.#{translation[0]}"), admin_pending_translations_path(:language => translation[0], :type => 'pending') %>
13
+ <%= link_to t("translations.locales.#{translation[0]}"), admin_pending_translations_path(:language => translation[0]) %>
14
14
  <span class="count"><%= translation[1].size %></span>
15
15
  </li>
16
16
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>:: Admin ::</title>
4
4
  <%= stylesheet_link_tag ['reset', 'font', 'form', 'admin'] %>
5
- <%= javascript_include_tag ['jquery', 'jquery-ui.min', 'autoresize.jquery.min', 'rails', 'admin'] %>
5
+ <%= javascript_include_tag ['jquery', 'jquery-ui.min', 'autoresize.jquery.min', 'rails', 'form', 'admin'] %>
6
6
  <%= csrf_meta_tag %>
7
7
 
8
8
  <%= yield(:head) %>
@@ -1,8 +1,9 @@
1
- <div id="toplinks">
1
+ <div id="toplinks">
2
2
  <% if user_signed_in? %>
3
- <%= t('.signed_in_as', :user => current_user.email) %>.
3
+ <%= t('admin.signed_in_as', :user => current_user.email) %>.
4
4
  <%= link_to t('.sign_out'), destroy_user_session_path %>
5
5
  <% else %>
6
6
  <%= link_to t('.sign_up'), new_user_registration_path %> <%= t('.or') %> <%= link_to t('.sign_in'), new_user_session_path %>
7
7
  <% end %>
8
+ &nbsp;<a href='/'><%= t('admin.website_home') %></a>
8
9
  </div>
@@ -4,6 +4,6 @@ fr:
4
4
  pages: Pages
5
5
  users: Utilisateurs
6
6
  categories: Catégories
7
- layouts:
8
- admin:
9
- signed_in_as: "Connecté en tant que %{user}"
7
+
8
+ website_home: Site
9
+ signed_in_as: "%{user}"
@@ -23,7 +23,7 @@ fr:
23
23
 
24
24
  search:
25
25
  title: Rechercher
26
- page_title: Par titre
26
+ page_title: Par titre ou contenu
27
27
  submit: Rechercher
28
28
 
29
29
 
@@ -2,7 +2,7 @@ require 'rails/generators'
2
2
  require 'rails/generators/migration'
3
3
 
4
4
  module Merrycms
5
- class InstallGenerator < Rails::Generators::Base
5
+ class InstallAuthGenerator < Rails::Generators::Base
6
6
  include Rails::Generators::Migration
7
7
 
8
8
  def self.source_root
@@ -25,55 +25,41 @@ module Merrycms
25
25
  def add_devise_routes
26
26
  route 'devise_for :users'
27
27
  end
28
-
28
+
29
+ def create_devise_migration_files
30
+ migration_template 'devise_create_users_migration.rb', 'db/migrate/devise_create_users.rb'
31
+ sleep 1
32
+ end
33
+
29
34
  def add_merrycms_routes
30
35
  route 'merrycms_routes'
31
36
  end
32
-
33
- def copy_locales
34
- directory "../../../../config/locales/fr/admin", "config/locales/fr/admin"
35
- end
36
37
 
37
- def create_migration_files
38
- migration_template 'devise_create_users_migration.rb', 'db/migrate/devise_create_users.rb'
39
- sleep 1
38
+ def create_user_management_migration_files
40
39
  migration_template 'create_roles_migration.rb', 'db/migrate/create_roles.rb'
41
40
  sleep 1
42
41
  migration_template 'roles_users_migration.rb', 'db/migrate/roles_users.rb'
43
42
  sleep 1
43
+ end
44
+
45
+ def create_page_and_category_migration_files
44
46
  migration_template 'create_pages_and_categories_migration.rb', 'db/migrate/create_pages_and_categories.rb'
45
47
  sleep 1
46
- migration_template 'create_translations_migration.rb', 'db/migrate/create_translations.rb'
47
- sleep 1
48
48
  end
49
49
 
50
- def copy_stylesheets
51
- copy_file '../../../../public/stylesheets/reset.css', 'public/stylesheets/reset.css'
52
- copy_file '../../../../public/stylesheets/font.css', 'public/stylesheets/font.css'
53
- copy_file '../../../../public/stylesheets/form.css', 'public/stylesheets/form.css'
54
- copy_file '../../../../public/stylesheets/login.css', 'public/stylesheets/login.css'
55
- copy_file '../../../../public/stylesheets/admin.css', 'public/stylesheets/admin.css'
56
- end
57
-
58
- def copy_javascripts
59
- copy_file '../../../../public/javascripts/admin.js', 'public/javascripts/jquery-ui.js'
60
- copy_file '../../../../public/javascripts/form.js', 'public/javascripts/form.js'
61
- copy_file '../../../../public/javascripts/admin.js', 'public/javascripts/admin.js'
62
- copy_file '../../../../public/javascripts/autoresize.jquery.min.js', 'public/javascripts/autoresize.jquery.min.js'
50
+ # pages and categories
51
+ def generate_slugs_table
52
+ invoke 'friendly_id'
63
53
  end
64
54
 
65
- def copy_images
66
- directory '../../../../public/images/merrycms', 'public/images/merrycms'
55
+ def create_translations_migration_files
56
+ migration_template 'create_translations_migration.rb', 'db/migrate/create_translations.rb'
57
+ sleep 1
67
58
  end
68
-
59
+
69
60
  def copy_locale_initializer
70
61
  copy_file 'locale_initializer.rb', 'config/initializers/locale.rb'
71
62
  end
72
-
73
- # pages and categories
74
- def generate_slugs_table
75
- invoke 'friendly_id'
76
- end
77
63
 
78
64
  end
79
65
  end
@@ -0,0 +1,40 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Merrycms
5
+ class InstallPagesGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ def self.source_root
9
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ def self.next_migration_number(dirname)
13
+ if ActiveRecord::Base.timestamped_migrations
14
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
15
+ else
16
+ "%.3d" % (current_migration_number(dirname) + 1)
17
+ end
18
+ end
19
+
20
+ def create_page_and_category_migration_files
21
+ migration_template 'create_pages_and_categories_migration.rb', 'db/migrate/create_pages_and_categories.rb'
22
+ sleep 1
23
+ end
24
+
25
+ # pages and categories
26
+ def generate_slugs_table
27
+ invoke 'friendly_id'
28
+ end
29
+
30
+ def create_translations_migration_files
31
+ migration_template 'create_translations_migration.rb', 'db/migrate/create_translations.rb'
32
+ sleep 1
33
+ end
34
+
35
+ def copy_locale_initializer
36
+ copy_file 'locale_initializer.rb', 'config/initializers/locale.rb'
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,30 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Merrycms
5
+ class InstallTranslationsGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ def self.source_root
9
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ def self.next_migration_number(dirname)
13
+ if ActiveRecord::Base.timestamped_migrations
14
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
15
+ else
16
+ "%.3d" % (current_migration_number(dirname) + 1)
17
+ end
18
+ end
19
+
20
+ def create_translations_migration_files
21
+ migration_template 'create_translations_migration.rb', 'db/migrate/create_translations.rb'
22
+ sleep 1
23
+ end
24
+
25
+ def copy_locale_initializer
26
+ copy_file 'locale_initializer.rb', 'config/initializers/locale.rb'
27
+ end
28
+
29
+ end
30
+ end
@@ -2,10 +2,23 @@ namespace :merrycms do
2
2
 
3
3
  desc "setup"
4
4
  task :setup => :environment do
5
- system("rails generate merrycms:install")
5
+ system("rails generate merrycms:install_auth")
6
+ system("rails generate merrycms:install_pages")
7
+ system("rails generate merrycms:install_translations")
8
+ system("rails generate jquery:install")
9
+
10
+ Rake::Task['merrycms:import_assets'].invoke
11
+
6
12
  Rake::Task['db:migrate'].invoke
7
13
  Rake::Task['merrycms:bootstrap'].invoke
8
- Rake::Task['jquery:install'].invoke
14
+ end
15
+
16
+ desc "Copies all merrycms assets to public/ directory"
17
+ task :import_assets => :environment do
18
+ merrycms_assets = File.expand_path(File.join(File.dirname(__FILE__), '../../../public/'))
19
+ command = "cp -R #{merrycms_assets} #{Rails.root}/"
20
+ puts command
21
+ system(command)
9
22
  end
10
23
 
11
24
  desc "bootstrap app"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Franck D'agostini
@@ -223,7 +223,9 @@ files:
223
223
  - config/locales/fr/admin/toplinks.fr.yml
224
224
  - config/locales/fr/admin/translations.fr.yml
225
225
  - config/locales/fr/admin/users.fr.yml
226
- - lib/generators/merrycms/install_generator.rb
226
+ - lib/generators/merrycms/install_auth_generator.rb
227
+ - lib/generators/merrycms/install_pages_generator.rb
228
+ - lib/generators/merrycms/install_translations_generator.rb
227
229
  - lib/generators/merrycms/templates/create_pages_and_categories_migration.rb
228
230
  - lib/generators/merrycms/templates/create_roles_migration.rb
229
231
  - lib/generators/merrycms/templates/create_translations_migration.rb