monologue 0.2.0 → 0.3.0

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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +28 -6
  4. data/app/assets/images/monologue/admin/select2.png +0 -0
  5. data/app/assets/javascripts/monologue/admin/application.js +6 -2
  6. data/app/assets/javascripts/monologue/admin/ckeditor-config.js +21 -0
  7. data/app/assets/javascripts/monologue/admin/posts.js +62 -0
  8. data/app/assets/stylesheets/monologue/admin/application.css +2 -1
  9. data/app/assets/stylesheets/monologue/admin/posts.sass +21 -0
  10. data/app/assets/stylesheets/monologue/blog/application.css +1 -1
  11. data/app/assets/stylesheets/monologue/blog/monologue.css +12 -1
  12. data/app/controllers/monologue/admin/base_controller.rb +2 -2
  13. data/app/controllers/monologue/admin/posts_controller.rb +31 -44
  14. data/app/controllers/monologue/admin/sessions_controller.rb +2 -2
  15. data/app/controllers/monologue/admin/users_controller.rb +39 -3
  16. data/app/controllers/monologue/application_controller.rb +7 -7
  17. data/app/controllers/monologue/posts_controller.rb +5 -7
  18. data/app/controllers/monologue/tags_controller.rb +8 -3
  19. data/app/form_builders/monologue_admin_form_builder.rb +12 -8
  20. data/app/helpers/monologue/application_helper.rb +9 -39
  21. data/app/helpers/monologue/html_helper.rb +35 -0
  22. data/app/helpers/monologue/tags_helper.rb +25 -0
  23. data/app/models/monologue/post.rb +38 -23
  24. data/app/models/monologue/tag.rb +3 -4
  25. data/app/models/monologue/tagging.rb +2 -0
  26. data/app/models/monologue/user.rb +13 -2
  27. data/app/sweepers/monologue/posts_sweeper.rb +2 -5
  28. data/app/views/layouts/monologue/admin.html.erb +2 -2
  29. data/app/views/layouts/monologue/admin/_nav_bar.html.erb +8 -16
  30. data/app/views/layouts/monologue/application.html.erb +1 -1
  31. data/app/views/layouts/monologue/application/_fb_open_graph.html.erb +2 -2
  32. data/app/views/layouts/monologue/application/_sidebar.html.erb +3 -1
  33. data/app/views/layouts/monologue/application/_twitter_cards.html.erb +2 -2
  34. data/app/views/monologue/admin/cache/_config.html.erb +1 -1
  35. data/app/views/monologue/admin/cache/show.html.erb +1 -1
  36. data/app/views/monologue/admin/posts/_form.html.erb +23 -9
  37. data/app/views/monologue/admin/posts/edit.html.erb +3 -3
  38. data/app/views/monologue/admin/posts/index.html.erb +5 -3
  39. data/app/views/monologue/admin/posts/new.html.erb +1 -1
  40. data/app/views/monologue/admin/sessions/new.html.erb +1 -1
  41. data/app/views/monologue/admin/users/_form.html.erb +5 -0
  42. data/app/views/monologue/admin/users/edit.html.erb +3 -7
  43. data/app/views/monologue/admin/users/index.html.erb +28 -0
  44. data/app/views/monologue/admin/users/new.html.erb +5 -0
  45. data/app/views/monologue/posts/_pagination.html.erb +2 -2
  46. data/app/views/monologue/posts/_post.html.erb +6 -8
  47. data/app/views/monologue/posts/_post_header.html.erb +16 -0
  48. data/app/views/monologue/posts/_social_sharing.html.erb +6 -6
  49. data/app/views/monologue/posts/feed.rss.builder +7 -8
  50. data/app/views/monologue/posts/index.html.erb +1 -1
  51. data/app/views/monologue/posts/show.html.erb +8 -8
  52. data/app/views/monologue/sidebar/_latest_posts.html.erb +1 -1
  53. data/app/views/monologue/sidebar/_latest_tweets.html.erb +1 -1
  54. data/app/views/monologue/sidebar/_tag_cloud.html.erb +1 -1
  55. data/config/locales/en.yml +81 -112
  56. data/config/locales/es.yml +148 -0
  57. data/config/locales/fr.yml +76 -110
  58. data/config/locales/it.yml +147 -0
  59. data/config/locales/pt.yml +147 -0
  60. data/config/locales/ro.yml +78 -110
  61. data/config/routes.rb +12 -10
  62. data/db/migrate/20120120193858_create_monologue_posts_revisions.rb +1 -1
  63. data/db/migrate/20120514194459_join_posts_and_tags.rb +1 -1
  64. data/db/migrate/20120526131841_migrate_old_urls.rb +3 -0
  65. data/db/migrate/20120612015727_delete_join_posts_tags.rb +1 -1
  66. data/db/migrate/20130108123111_move_user_id_to_post.rb +31 -0
  67. data/db/migrate/20130509015400_merge_revisions_into_posts.rb +40 -0
  68. data/db/seeds.rb +1 -1
  69. data/lib/monologue/engine.rb +6 -6
  70. data/lib/monologue/version.rb +1 -1
  71. data/lib/tasks/monologue_cache.rake +1 -1
  72. data/vendor/assets/javascripts/monologue/bootstrap/bootstrap-datepicker-es.js +7 -0
  73. data/vendor/assets/javascripts/monologue/bootstrap/bootstrap-datepicker-it.js +9 -0
  74. data/vendor/assets/javascripts/monologue/bootstrap/bootstrap-datepicker-pt.js +9 -0
  75. metadata +88 -78
  76. data/app/assets/javascripts/monologue/admin/tinymce-config.js +0 -21
  77. data/app/models/monologue/posts_revision.rb +0 -61
  78. data/app/views/monologue/posts/_revision_header.html.erb +0 -9
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40fc2b990c0a8647cd9da84ac89e602fea6d1c3a
4
+ data.tar.gz: 996f5bd9ffaa0e65c80f9f576dcd1df6566d1141
5
+ SHA512:
6
+ metadata.gz: f692ded8634a34d4cb731042b1cf741a102fefb505f9109d87b8b2feb1fc330be72eb3d8d330cf231da1b972027761108c6a6222abec92e9f6d97c50383d69fa
7
+ data.tar.gz: d4665bf2de9a72f3c0d8a9eaa5c0b168dd9a8b02b7dd93a31f7b488c4febff415cae8ffec62ad865235e90562381398dd8a2f6ec38fe4253b3d4e053335cea41
@@ -1,4 +1,4 @@
1
- Copyright 2012 YOURNAME
1
+ Copyright 2012 Jean-Philippe Boily
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,18 @@
1
- # MONOLOGUE
1
+ # Monologue
2
2
  Monologue is a basic mountable blogging engine in Rails built to be easily mounted in an already existing Rails app, but it can also be used alone.
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/monologue.png)](http://badge.fury.io/rb/monologue)
4
5
  [![Build Status](https://secure.travis-ci.org/jipiboily/monologue.png)](http://travis-ci.org/jipiboily/monologue)
6
+ [![Code Climate](https://codeclimate.com/github/jipiboily/monologue.png)](https://codeclimate.com/github/jipiboily/monologue)
7
+ [![Coverage Status](https://coveralls.io/repos/jipiboily/monologue/badge.png?branch=master)](https://coveralls.io/r/jipiboily/monologue?branch=master)
5
8
 
9
+ ## IMPORTANT: version
10
+
11
+ This README is for Monologue 0.3.X.
12
+
13
+ ## Upgrade and changes
14
+
15
+ To know how to upgrade, see [UPGRADE.md](https://github.com/jipiboily/monologue/blob/master/UPGRADE.md) file. If you want to know what changed since the last versions, see [CHANGELOG.md](https://github.com/jipiboily/monologue/blob/master/CHANGELOG.md).
6
16
 
7
17
  ## Questions? Problems? Documentation?
8
18
 
@@ -14,9 +24,9 @@ Monologue is a basic mountable blogging engine in Rails built to be easily mount
14
24
  - Rails mountable engine (fully named spaced and mountable in an already existing app)
15
25
  - tested
16
26
  - back to basics: few features
17
- - it has post revisions (no UI to choose published revision yet, but it keeps your modification history)
18
27
  - tags (or categories)
19
28
  - RSS
29
+ - multiple users
20
30
  - support for Google Analytics and Gaug.es tags
21
31
  - few external dependencies (no Devise or Sorcery, etc…) so we don't face problem integrating with existing Rails app.([Rails mountable engines: dependency nightmare?](http://jipiboily.com/2012/rails-mountable-engines-dependency-nightmare))
22
32
  - comments are handled by [disqus](http://disqus.com/)
@@ -26,7 +36,6 @@ Monologue is a basic mountable blogging engine in Rails built to be easily mount
26
36
  - bonus: there is a `[monologue-markdown](https://github.com/jipiboily/monologue-markdown)` extension
27
37
 
28
38
  ### missing features
29
- - UI for posts revisions and to manage user
30
39
  - see [roadmap](https://github.com/jipiboily/monologue/wiki/Roadmap)!
31
40
 
32
41
 
@@ -46,8 +55,11 @@ Add this to your route file (`config/route.rb`)
46
55
  # If you would like to change where this engine is mounted, simply change the :at option to something different.
47
56
  #
48
57
  # We ask that you don't use the :as option here, as Monologue relies on it being the default of "monologue"
49
- mount Monologue::Engine, :at => '/' # or whatever path, be it "/blog" or "/monologue"
58
+ mount Monologue::Engine, at: '/' # or whatever path, be it "/blog" or "/monologue"
50
59
  ```
60
+ For example, if you decide to mount it at `/blog`, the admin section will be available at `/blog/monologue`.
61
+ Here we decide to use monologue as default route mounting it at `/`, it means that the admin section will directly
62
+ be available at `/monologue`.
51
63
 
52
64
  ### 3. Migrate Monologue's database tables
53
65
  Run these commands:
@@ -70,10 +82,16 @@ This is all done in an initializer file, say `config/initializers/monologue.rb`.
70
82
  Start your server and head on [http://localhost:3000/monologue](http://localhost:3000/monologue) to log in the admin section.
71
83
 
72
84
  ### Note to Heroku users
73
- Additionnal step: turn caching off in `config/environments/production.rb`:
85
+ 1. Additionnal step: turn caching off in `config/environments/production.rb`:
74
86
  ```ruby
75
87
  config.action_controller.perform_caching = false
76
88
  ```
89
+ 2. If you use compiled assets, I recommend you to add `gem "tinymce-rails"` to your Gemfile otherwise you might not be able to post an article.
90
+
91
+ ### Note to users
92
+ Monologue is using his own tables. If you want to use your own tables with monologue (for example the User table)
93
+ this might help you to monkey patch [Monkey Patch](https://gist.github.com/jipiboily/776d907fc932640ac59a)
94
+
77
95
 
78
96
  ## Enable caching
79
97
  [See full caching doc here.](https://github.com/jipiboily/monologue/wiki/Configure-Monologue's-cache)
@@ -85,6 +103,10 @@ See the [Wiki - Customizations](https://github.com/jipiboily/monologue/wiki/Cust
85
103
  - Rails 3.1 +
86
104
  - Database: MySQL & Postgres are supported but other databases might work too.
87
105
 
106
+ ## Authors
107
+ * Jean-Philippe Boily, [@jipiboily](https://github.com/jipiboily)
108
+ * Michael Sevestre, [@msevestre](https://github.com/msevestre)
109
+
88
110
  ## Contribute
89
111
  Fork it, then pull request. Please add tests for your feature or bug fix.
90
112
 
@@ -93,4 +115,4 @@ You will need to install this before running the test suite:
93
115
 
94
116
  ## Thanks to
95
117
 
96
- Zurb for the "social foundicons".
118
+ Zurb for the "social foundicons".
@@ -9,5 +9,9 @@
9
9
  //= require monologue/bootstrap/bootstrap.min
10
10
  //= require monologue/bootstrap/bootstrap-datepicker
11
11
  //= require monologue/bootstrap/bootstrap-datepicker-fr
12
- //= require tinymce-jquery
13
- //= require_tree .
12
+ //= require monologue/bootstrap/bootstrap-datepicker-pt
13
+ //= require monologue/bootstrap/bootstrap-datepicker-es
14
+ //= require ckeditor/init
15
+ //= require monologue/admin/ckeditor-config
16
+ //= require monologue/admin/posts
17
+ //= require select2
@@ -0,0 +1,21 @@
1
+ $(function() {
2
+
3
+ // Full configuation can be found under http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar
4
+ CKEDITOR.config.toolbar = 'Basic';
5
+ CKEDITOR.config.toolbar_Basic =
6
+ [
7
+ { name: 'document', items : [ 'Source','-','Save','NewPage','DocProps','Preview','Print','-','Templates' ] },
8
+ { name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
9
+ { name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','SpellChecker', 'Scayt' ] },
10
+ { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','Subscript','Superscript','-','RemoveFormat' ] },
11
+ '/',
12
+ { name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote','CreateDiv',
13
+ '-','JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl' ] },
14
+ { name: 'links', items : [ 'Link','Unlink','Anchor' ] },
15
+ { name: 'insert', items : [ 'Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak','Iframe' ] },
16
+ '/',
17
+ { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
18
+ { name: 'colors', items : [ 'TextColor','BGColor' ] },
19
+ { name: 'tools', items : [ 'Maximize', 'ShowBlocks' ] }
20
+ ];
21
+ });
@@ -0,0 +1,62 @@
1
+ $(document).ready (function(){
2
+
3
+ var preview = {
4
+ el: null,
5
+
6
+ // initialize - bind events, etc.
7
+ init: function(selector) {
8
+ this.el = $(selector);
9
+ if (this.el.length == 0) { return;}
10
+ $(this.el.attr("data-trigger")).click(this, this.open);
11
+ this.el.find("[data-dismiss='post-preview']").click(this, this.close);
12
+ },
13
+
14
+ // open preview
15
+ open: function(e) {
16
+ var el = e.data.el;
17
+ var iframe = el.find("iframe")[0];
18
+ if(iframe.contentDocument){
19
+ var doc = iframe.contentDocument;
20
+ }
21
+ else if(iframe.contentWindow){
22
+ var doc = iframe.contentWindow.document;
23
+ } else {
24
+ var doc = iframe.document;
25
+ }
26
+
27
+ $("#post_content").val(CKEDITOR.instances["post_content"].getData()); // update textarea with CKEDITOR content.
28
+ $.post(el.attr("data-url"), $("form").serialize(), function(data) {
29
+ doc.open();
30
+ doc.writeln(data);
31
+ doc.close();
32
+ $(doc).keydown(e.data, e.data.keydown);
33
+ });
34
+
35
+ // show preview & hide scrollbars
36
+ el.show();
37
+ $("body").attr("style", "overflow:hidden;");
38
+
39
+ // look for esc
40
+ $(document).on("keydown.post-preview", e.data, e.data.keydown);
41
+ },
42
+
43
+ // close preview on esc key.
44
+ keydown: function(e) {
45
+ if (e.keyCode==27) {
46
+ e.data.close();
47
+ }
48
+ },
49
+
50
+ // close preview
51
+ close: function(e) {
52
+ var el = (e==undefined)? this.el: e.data.el;
53
+ el.hide();
54
+ $("body").attr("style", "overflow:auto;");
55
+ $(document).off("keydown.post-preview");
56
+ }
57
+ }
58
+
59
+
60
+ // initialize preview.
61
+ preview.init("[data-toggle='post-preview']");
62
+ })
@@ -6,5 +6,6 @@
6
6
  *= require monologue/bootstrap/bootstrap.min
7
7
  *= require monologue/bootstrap/bootstrap-responsive.min
8
8
  *= require monologue/bootstrap/bootstrap-datepicker
9
- *= require_tree .
9
+ *= require select2
10
+ *= require monologue/admin/posts
10
11
  */
@@ -0,0 +1,21 @@
1
+ .post-preview
2
+ background: #fff
3
+ opacity: 1
4
+
5
+ iframe
6
+ width: 100%
7
+ height: 100%
8
+
9
+ .post-preview-inner
10
+ position: fixed
11
+ top: 0
12
+ opacity: 0.9
13
+ width: 100%
14
+ .navbar
15
+ margin-right: 20px
16
+
17
+ .select2-search-choice-close
18
+ background: url("select2.png") right top no-repeat
19
+
20
+ .select2-container
21
+ width: 20em
@@ -7,7 +7,7 @@
7
7
  *= require monologue/blog/skeleton/skeleton
8
8
  *= require monologue/blog/skeleton/layout
9
9
  *= require monologue/foundation_icons/social_foundicons
10
- *= require_tree .
10
+ *= require monologue/blog/monologue
11
11
  *= require monologue/blog/fonts
12
12
  *= require monologue/blog/custom
13
13
  */
@@ -33,7 +33,18 @@ a.social {
33
33
  font-size: 30px;
34
34
  }
35
35
 
36
+ .post-header span {
37
+ text-transform: uppercase;
38
+ font-weight: bold;
39
+ }
36
40
 
41
+ .post-header span:after{
42
+ content: "|";
43
+ }
44
+
45
+ .post-header span:last-child:after {
46
+ content: "";
47
+ }
37
48
  /* pagination */
38
49
 
39
50
  #pagination {
@@ -91,7 +102,7 @@ a.social {
91
102
  }
92
103
 
93
104
  /* tags */
94
- #tags {
105
+ .tags {
95
106
  margin-top: 20px;
96
107
  margin-bottom: 20px;
97
108
  }
@@ -5,8 +5,8 @@ class Monologue::Admin::BaseController < Monologue::ApplicationController
5
5
  layout "layouts/monologue/admin"
6
6
 
7
7
  def authenticate_user!
8
- if current_user.nil?
9
- redirect_to admin_login_url, :alert => I18n.t("monologue.admin.login.need_auth")
8
+ if monologue_current_user.nil?
9
+ redirect_to admin_login_url, alert: I18n.t("monologue.admin.login.need_auth")
10
10
  end
11
11
  end
12
12
  end
@@ -1,54 +1,43 @@
1
1
  class Monologue::Admin::PostsController < Monologue::Admin::BaseController
2
2
  respond_to :html
3
- cache_sweeper Monologue::PostsSweeper, :only => [:create, :update, :destroy]
4
- before_filter :load_post_and_revisions, :only => [:edit, :update]
5
-
3
+ cache_sweeper Monologue::PostsSweeper, only: [:create, :update, :destroy]
4
+ before_filter :load_post, only: [:edit, :update]
5
+
6
6
  def index
7
7
  @posts = Monologue::Post.default
8
8
  end
9
9
 
10
10
  def new
11
11
  @post = Monologue::Post.new
12
- @revision = @post.posts_revisions.build
13
12
  end
14
-
13
+
14
+ ## Preview a post without saving.
15
+ def preview
16
+ # mockup our models for preview.
17
+ @post = Monologue::Post.new(params[:post])
18
+ @post.user_id = monologue_current_user.id
19
+ @post.published_at = Time.zone.now
20
+
21
+ # render it exactly as it would display when live.
22
+ render "/monologue/posts/show", layout: Monologue.layout || "/layouts/monologue/application"
23
+ end
24
+
15
25
  def create
16
- params[:post][:posts_revisions_attributes] = {}
17
- params[:post][:posts_revisions_attributes][0] = params[:post][:posts_revision]
18
- params[:post].delete("posts_revision")
19
- tags = params[:post].delete(:tag_list)
20
26
  @post = Monologue::Post.new(params[:post])
21
- @revision = @post.posts_revisions.first
22
- @revision.user_id = current_user.id
23
- save_tags(tags)
27
+ @post.user_id = monologue_current_user.id
24
28
  if @post.save
25
- if @revision.published_at > DateTime.now && @post.published && ActionController::Base.perform_caching
26
- flash[:warning] = I18n.t("monologue.admin.posts.create.created_with_future_date_and_cache")
27
- else
28
- flash[:notice] = I18n.t("monologue.admin.posts.create.created")
29
- end
30
- redirect_to edit_admin_post_path(@post)
29
+ prepare_flash_and_redirect_to_edit()
31
30
  else
32
31
  render :new
33
32
  end
34
33
  end
35
34
 
36
35
  def edit
37
- @revision = @post.active_revision
38
36
  end
39
37
 
40
38
  def update
41
- @post.published = params[:post][:published]
42
- @revision = @post.posts_revisions.build(params[:post][:posts_revision])
43
- @revision.user_id = current_user.id
44
- save_tags(params[:post][:tag_list])
45
- if @post.save
46
- if @revision.published_at > DateTime.now && @post.published && ActionController::Base.perform_caching
47
- flash[:warning] = I18n.t("monologue.admin.posts.update.saved_with_future_date_and_cache")
48
- else
49
- flash[:notice] = I18n.t("monologue.admin.posts.update.saved")
50
- end
51
- redirect_to edit_admin_post_path(@post)
39
+ if @post.update_attributes(params[:post])
40
+ prepare_flash_and_redirect_to_edit()
52
41
  else
53
42
  render :edit
54
43
  end
@@ -57,25 +46,23 @@ class Monologue::Admin::PostsController < Monologue::Admin::BaseController
57
46
  def destroy
58
47
  post = Monologue::Post.find(params[:id])
59
48
  if post.destroy
60
- redirect_to admin_posts_path, :notice => I18n.t("monologue.admin.posts.delete.removed")
49
+ redirect_to admin_posts_path, notice: I18n.t("monologue.admin.posts.delete.removed")
61
50
  else
62
- redirect_to admin_posts_path, :alert => I18n.t("monologue.admin.posts.delete.failed")
51
+ redirect_to admin_posts_path, alert: I18n.t("monologue.admin.posts.delete.failed")
63
52
  end
64
53
  end
65
54
 
66
- private
67
- def save_tags(tags)
68
- @post.tag!(tags.split(","))
55
+ private
56
+ def load_post
57
+ @post = Monologue::Post.find(params[:id])
69
58
  end
70
59
 
71
- def load_post_and_revisions
72
- @post = Monologue::Post.includes(:posts_revisions).find(params[:id])
73
- end
74
-
75
- helper_method :tag_list_for
76
-
77
- def tag_list_for(tags)
78
- tags.map { |tag| tag.name }.join(", ") if tags
60
+ def prepare_flash_and_redirect_to_edit
61
+ if @post.published_in_future? && ActionController::Base.perform_caching
62
+ flash[:warning] = I18n.t("monologue.admin.posts.#{params[:action]}.saved_with_future_date_and_cache")
63
+ else
64
+ flash[:notice] = I18n.t("monologue.admin.posts.#{params[:action]}.saved")
65
+ end
66
+ redirect_to edit_admin_post_path(@post)
79
67
  end
80
-
81
68
  end
@@ -8,7 +8,7 @@ class Monologue::Admin::SessionsController < Monologue::Admin::BaseController
8
8
  user = Monologue::User.find_by_email(params[:email])
9
9
  if user && user.authenticate(params[:password])
10
10
  session[:monologue_user_id] = user.id
11
- redirect_to admin_url, :notice => t("monologue.admin.sessions.messages.logged_in")
11
+ redirect_to admin_url, notice: t("monologue.admin.sessions.messages.logged_in")
12
12
  else
13
13
  flash.now.alert = t("monologue.admin.sessions.messages.invalid")
14
14
  render "new"
@@ -17,6 +17,6 @@ class Monologue::Admin::SessionsController < Monologue::Admin::BaseController
17
17
 
18
18
  def destroy
19
19
  session[:monologue_user_id] = nil
20
- redirect_to admin_url, :notice => t("monologue.admin.sessions.messages.logged_out")
20
+ redirect_to admin_url, notice: t("monologue.admin.sessions.messages.logged_out")
21
21
  end
22
22
  end
@@ -1,13 +1,49 @@
1
1
  class Monologue::Admin::UsersController < Monologue::Admin::BaseController
2
+
3
+ before_filter :load_user, except: [:index, :new, :create]
4
+
2
5
  def edit
3
- @user = current_user
6
+
7
+ end
8
+
9
+ def new
10
+ @user = Monologue::User.new
4
11
  end
5
12
 
6
13
  def update
7
- @user = current_user
8
14
  if @user.update_attributes(params[:user])
9
15
  flash.notice = "User modified"
16
+ redirect_to admin_users_path
17
+ else
18
+ render :edit
10
19
  end
11
- render :edit
12
20
  end
21
+
22
+ def destroy
23
+ if @user.destroy
24
+ redirect_to admin_users_path, notice: I18n.t("monologue.admin.users.delete.removed", user: @user.name)
25
+ else
26
+ redirect_to admin_users_path, alert: I18n.t("monologue.admin.users.delete.failed", user: @user.name)
27
+ end
28
+ end
29
+
30
+ def create
31
+ @user = Monologue::User.new(params[:user])
32
+ if @user.save
33
+ flash.notice = I18n.t("monologue.admin.users.create.success")
34
+ redirect_to admin_users_path
35
+ else
36
+ render :new
37
+ end
38
+ end
39
+
40
+ def index
41
+ @users = Monologue::User.all
42
+ end
43
+
44
+ private
45
+ def load_user
46
+ @user = Monologue::User.find(params[:id])
47
+ end
48
+
13
49
  end