railswiki 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (101) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +185 -0
  4. data/Rakefile +24 -0
  5. data/app/assets/config/railswiki_manifest.js +2 -0
  6. data/app/assets/javascripts/railswiki/application.js +13 -0
  7. data/app/assets/javascripts/railswiki/histories.js +2 -0
  8. data/app/assets/javascripts/railswiki/invites.js +2 -0
  9. data/app/assets/javascripts/railswiki/pages.js +2 -0
  10. data/app/assets/javascripts/railswiki/sessions.js +2 -0
  11. data/app/assets/javascripts/railswiki/uploaded_files.js +2 -0
  12. data/app/assets/javascripts/railswiki/users.js +2 -0
  13. data/app/assets/stylesheets/railswiki/application.css +15 -0
  14. data/app/assets/stylesheets/railswiki/histories.css +4 -0
  15. data/app/assets/stylesheets/railswiki/invites.css +4 -0
  16. data/app/assets/stylesheets/railswiki/pages.scss +55 -0
  17. data/app/assets/stylesheets/railswiki/sessions.css +4 -0
  18. data/app/assets/stylesheets/railswiki/uploaded_files.scss +54 -0
  19. data/app/assets/stylesheets/railswiki/users.css +4 -0
  20. data/app/controllers/railswiki/application_controller.rb +126 -0
  21. data/app/controllers/railswiki/histories_controller.rb +48 -0
  22. data/app/controllers/railswiki/invites_controller.rb +61 -0
  23. data/app/controllers/railswiki/pages_controller.rb +141 -0
  24. data/app/controllers/railswiki/sessions_controller.rb +75 -0
  25. data/app/controllers/railswiki/uploaded_files_controller.rb +100 -0
  26. data/app/controllers/railswiki/users_controller.rb +55 -0
  27. data/app/helpers/railswiki/application_helper.rb +26 -0
  28. data/app/helpers/railswiki/histories_helper.rb +4 -0
  29. data/app/helpers/railswiki/invites_helper.rb +4 -0
  30. data/app/helpers/railswiki/pages_helper.rb +76 -0
  31. data/app/helpers/railswiki/sessions_helper.rb +4 -0
  32. data/app/helpers/railswiki/title_helper.rb +7 -0
  33. data/app/helpers/railswiki/uploaded_files_helper.rb +4 -0
  34. data/app/helpers/railswiki/users_helper.rb +4 -0
  35. data/app/helpers/railswiki/wiki_helper.rb +189 -0
  36. data/app/jobs/railswiki/application_job.rb +4 -0
  37. data/app/mailers/railswiki/application_mailer.rb +6 -0
  38. data/app/models/railswiki/application_record.rb +5 -0
  39. data/app/models/railswiki/history.rb +14 -0
  40. data/app/models/railswiki/invite.rb +20 -0
  41. data/app/models/railswiki/page.rb +56 -0
  42. data/app/models/railswiki/uploaded_file.rb +32 -0
  43. data/app/models/railswiki/user.rb +27 -0
  44. data/app/uploaders/railswiki/file_uploader.rb +56 -0
  45. data/app/views/layouts/railswiki/application.html.erb +25 -0
  46. data/app/views/railswiki/histories/index.html.erb +33 -0
  47. data/app/views/railswiki/histories/show.html.erb +17 -0
  48. data/app/views/railswiki/invites/_form.html.erb +38 -0
  49. data/app/views/railswiki/invites/index.html.erb +39 -0
  50. data/app/views/railswiki/invites/new.html.erb +7 -0
  51. data/app/views/railswiki/invites/show.html.erb +34 -0
  52. data/app/views/railswiki/pages/_form.html.erb +144 -0
  53. data/app/views/railswiki/pages/edit.html.erb +8 -0
  54. data/app/views/railswiki/pages/history.html.erb +11 -0
  55. data/app/views/railswiki/pages/index.html.erb +72 -0
  56. data/app/views/railswiki/pages/new.html.erb +7 -0
  57. data/app/views/railswiki/pages/show.html.erb +36 -0
  58. data/app/views/railswiki/sessions/no_invite.erb +7 -0
  59. data/app/views/railswiki/sessions/not_authorized.html.erb +12 -0
  60. data/app/views/railswiki/uploaded_files/_form.html.erb +31 -0
  61. data/app/views/railswiki/uploaded_files/_inline.html.erb +5 -0
  62. data/app/views/railswiki/uploaded_files/edit.html.erb +8 -0
  63. data/app/views/railswiki/uploaded_files/file_dialog.html.erb +11 -0
  64. data/app/views/railswiki/uploaded_files/image_dialog.html.erb +11 -0
  65. data/app/views/railswiki/uploaded_files/index.html.erb +36 -0
  66. data/app/views/railswiki/uploaded_files/new.html.erb +7 -0
  67. data/app/views/railswiki/uploaded_files/show.html.erb +29 -0
  68. data/app/views/railswiki/users/_form.html.erb +29 -0
  69. data/app/views/railswiki/users/edit.html.erb +8 -0
  70. data/app/views/railswiki/users/index.html.erb +37 -0
  71. data/app/views/railswiki/users/show.html.erb +59 -0
  72. data/app/views/shared/_formatting.md.erb +29 -0
  73. data/app/views/shared/_histories.html.erb +21 -0
  74. data/app/views/shared/_layout.html.erb +17 -0
  75. data/app/views/shared/_menu.html.erb +15 -0
  76. data/app/views/shared/_meta.html.erb +1 -0
  77. data/app/views/shared/_notices.html.erb +3 -0
  78. data/app/views/shared/_roles.html.erb +12 -0
  79. data/app/views/shared/_search.md.erb +5 -0
  80. data/config/initializers/carrierwave.rb +6 -0
  81. data/config/initializers/omniauth.rb +16 -0
  82. data/config/initializers/session_store.rb +1 -0
  83. data/config/routes.rb +25 -0
  84. data/db/migrate/20170420000841_create_railswiki_pages.rb +10 -0
  85. data/db/migrate/20170420010111_add_sessions_table.rb +12 -0
  86. data/db/migrate/20170420010147_create_railswiki_users.rb +14 -0
  87. data/db/migrate/20170420021039_add_lowercase_title_to_page.rb +5 -0
  88. data/db/migrate/20170420021840_create_railswiki_histories.rb +11 -0
  89. data/db/migrate/20170420235420_add_email_and_image_to_user.rb +8 -0
  90. data/db/migrate/20170421000333_add_last_login_to_user.rb +5 -0
  91. data/db/migrate/20170421010945_add_role_to_user.rb +7 -0
  92. data/db/migrate/20170421020932_create_railswiki_uploaded_files.rb +10 -0
  93. data/db/migrate/20170421030140_add_title_to_uploaded_file.rb +5 -0
  94. data/db/migrate/20170517224700_create_railswiki_invites.rb +12 -0
  95. data/db/migrate/20170517234452_add_role_to_invite.rb +5 -0
  96. data/db/migrate/20170622033540_set_all_mysql_tables_to_utf8.rb +54 -0
  97. data/lib/railswiki.rb +5 -0
  98. data/lib/railswiki/engine.rb +14 -0
  99. data/lib/railswiki/version.rb +3 -0
  100. data/lib/tasks/railswiki_tasks.rake +4 -0
  101. metadata +255 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16ff0c2ac029de418449afc75c8e33fd6af038d7
4
+ data.tar.gz: 99faf6315a3dc2ea27634d1fdac059e8564ffd86
5
+ SHA512:
6
+ metadata.gz: 7d2b2c098430a8341a0951d47dc14abfb735667e4f38d5947c49ec5fb0ed08574b4a4341a8d7e4841a600ec56e17237eb43873e501d62e2388e2d21a5fa2a41c
7
+ data.tar.gz: 97688e4fb4f443f266bbbbe60309771692df6f46725cb2f94d0c240a97b448153c4b45ee4aef6e2f5faa8d40b5d7dd6be0185de46eb00e83f68ad933f3fbbf48
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Jevon Wright
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,185 @@
1
+ # Railswiki
2
+ A wiki engine in Rails 5.
3
+
4
+ ## Usage
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'railswiki'
10
+
11
+ # for loading secrets
12
+ gem 'figaro'
13
+ gem 'dotenv-rails'
14
+ ```
15
+
16
+ And then execute:
17
+ ```bash
18
+ $ bundle
19
+ ```
20
+
21
+ Then enable in your application in `config/routes.rb`:
22
+ ```ruby
23
+ Rails.application.routes.draw do
24
+ mount Railswiki::Engine, at: "/wiki"
25
+
26
+ get "/auth/google_login/callback" => "railswiki/sessions#create"
27
+ get "/auth/google_login" => "railswiki/sessions#create", as: :login
28
+
29
+ root to: "railswiki/pages#show", id: "Home"
30
+ end
31
+ ```
32
+
33
+ Install and run migrations:
34
+
35
+ ```bash
36
+ $ rake railties:install:migrations
37
+ $ rake db:migrate
38
+ ```
39
+
40
+ Enable `config/secrets.yml` to load secrets from ENV (using `figaro`):
41
+
42
+ ```yaml
43
+ # config/secrets.yml
44
+
45
+ # Do not keep production secrets in the repository,
46
+ # instead read values from the environment.
47
+ production:
48
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
49
+ ```
50
+
51
+ Set your secrets in a `.env` file in root (using `dotenv-rails`):
52
+
53
+ ```yaml
54
+ SECRET_KEY_BASE: "xyz"
55
+ OAUTH_CLIENT_ID: "xyz"
56
+ OAUTH_CLIENT_SECRET: "xyz"
57
+ ```
58
+
59
+ Get these values by [logging into your Google Developers Console](http://www.jevon.org/wiki/Google_OAuth2_with_Ruby_on_Rails).
60
+
61
+ Install webpacker, adding `railswiki` as a dependency:
62
+
63
+ ```bash
64
+ $ rails webpacker:install
65
+ $ yarn add https://github.com/soundasleep/railswiki
66
+ $ yarn install
67
+ ```
68
+
69
+ Add to your `app/javascript/packs/application.js`:
70
+
71
+ ```js
72
+ // javascripts
73
+ import SimpleMDE from 'simplemde'
74
+ import Tingle from 'tingle.js'
75
+
76
+ window.SimpleMDE = SimpleMDE
77
+ window.tingle = Tingle
78
+
79
+ // stylesheets
80
+
81
+ // I have NO idea why the src/ is broken but debug/ works - it looks like src/
82
+ // is missing some extra styles that aren't being included properly. who knows.
83
+ // import "simplemde/src/css/simplemde.css"
84
+ import "simplemde/debug/simplemde.css"
85
+ import 'tingle.js/src/tingle.css'
86
+ ```
87
+
88
+ Run `bin/webpack` or `bin/webpack-dev-server` (hot reloading) to compile the webpacker pack.
89
+
90
+ You can now host locally and visit http://localhost:3000/wiki:
91
+
92
+ ```bash
93
+ $ rails s
94
+ ```
95
+
96
+ ## Extending
97
+
98
+ In your local app, edit the app/assets/javascripts/ and app/assets/stylesheets as normal.
99
+ They will automatically be picked up.
100
+
101
+ You can also override individual views from _railswiki_ by creating e.g. `app/views/railswiki/pages/show.html.erb`.
102
+
103
+ ### Custom page titles
104
+
105
+ In `app/helpers/railswiki/title_helper.rb`:
106
+
107
+ ```ruby
108
+ module Railswiki::TitleHelper
109
+ def title(page_title)
110
+ page_title = ["My Very First Wiki"] if page_title == ["Home"]
111
+
112
+ content_for(:title) { page_title.join(" - ") }
113
+ end
114
+ end
115
+ ```
116
+
117
+ ### Use slugs (/title) rather than Wiki (/wiki/Title)
118
+
119
+ Create a new initialiser to enable slugs, rather than wiki pages:
120
+
121
+ ```ruby
122
+ # config/initializers/railswiki_slugs.rb
123
+
124
+ Railswiki::Engine.use_slugs = true
125
+ ```
126
+
127
+ And add to your `routes.rb`, before your `root` route:
128
+
129
+ ```ruby
130
+ get "*path", to: 'railswiki/pages#show', via: :get, as: :slug
131
+ ```
132
+
133
+ ## Deploying
134
+
135
+ Check out [DEPLOY.md](DEPLOY.md) for instructions to deploy using Capistrano onto Apache/Passenger/MySQL.
136
+
137
+ ## Supported
138
+
139
+ 1. Making pages, editing pages
140
+ 1. Assigning permissions to users
141
+ 1. Uploading files and images, images can be scaled and linked to external URLs
142
+ 1. Existing image dialog in wysiwyg editor (uploading images remotely is too hard)
143
+ 1. Existing file dialog in wysiwyg editor
144
+ 1. Invite users
145
+ 1. Prevent navigating/reloading with unsaved changes
146
+ 1. Templates can be included using `{{template}}`
147
+ 1. Search with `{{Special:Search}}` template
148
+ 1. Rails 5.1
149
+ 1. Uses yarn/webpack for Javascript assets (though it's a bit messy - [waiting for webpack support for Rails Engines](https://github.com/rails/webpacker/issues/348))
150
+
151
+ ## MVP
152
+
153
+ 1. A nice default style
154
+ 1. Put dialog Javascript into assets/, not inline
155
+
156
+ ## TODO
157
+
158
+ 1. Use Ruby 2.4+
159
+ 1. Make site accessible to screen readers (like ChromeVox) by default
160
+ 1. Allow images to have descriptions, which are used for screen readers
161
+ 1. Allow images to be linked as Image:N rather than full paths
162
+ 1. Allow files, images to be renamed (change title)
163
+ 1. All the schemas require null set
164
+ 1. Rspec tests
165
+ 2. Cucumber tests
166
+ 3. Travis-ci integration
167
+ 4. Demo site on Heroku
168
+ 5. Screenshot
169
+ 1. Uploads [persist across validations](https://github.com/carrierwaveuploader/carrierwave#making-uploads-work-across-form-redisplays) and can be [uploaded from remote URLs](https://github.com/carrierwaveuploader/carrierwave#uploading-files-from-a-remote-location)
170
+ 1. Support [strikethrough, pretty code blocks, etc](https://github.com/vmg/redcarpet) and list in Special:Formatting
171
+ 1. "What Links Here"
172
+ 1. "Page Categories"
173
+ 1. Clicking "sign in" at the bottom of the page redirects to the page you were on
174
+
175
+ ## Sites using Railswiki
176
+
177
+ * http://outerspaces.org.nz ([source](https://github.com/soundasleep/outerspaces))
178
+
179
+ ## Contributing
180
+
181
+ Contribution directions go here.
182
+
183
+ ## License
184
+
185
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,24 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Railswiki'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+ load 'rails/tasks/statistics.rake'
20
+
21
+
22
+
23
+ require 'bundler/gem_tasks'
24
+
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/railswiki .js
2
+ //= link_directory ../stylesheets/railswiki .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,55 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ .wiki-template {
7
+ &.wiki-Special_Search {
8
+ display: inline;
9
+
10
+ &, form, div, p, label {
11
+ display: inline-block;
12
+ border: 0;
13
+ padding: 0;
14
+ clear: none;
15
+ }
16
+ p {
17
+ display: inline;
18
+ margin: 0;
19
+ }
20
+ h3, label, input[type=submit] {
21
+ display: none;
22
+ }
23
+ }
24
+ }
25
+
26
+ .wiki-Special_Header {
27
+ float: left;
28
+ max-width: 50%;
29
+ }
30
+
31
+ .menu {
32
+ float: right;
33
+ max-width: 50%;
34
+ text-align: right;
35
+ margin-bottom: 20px;
36
+
37
+ p {
38
+ margin: 0;
39
+ padding: 0;
40
+ }
41
+ }
42
+
43
+ .content {
44
+ clear: both;
45
+ }
46
+
47
+ .end-of-content {
48
+ clear: both;
49
+ }
50
+
51
+ .error {
52
+ background: #fcc;
53
+ border: 1px solid #c99;
54
+ padding: 1em;
55
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,54 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
5
+
6
+ .insert-image {
7
+ ul.uploaded-images {
8
+ list-style: none;
9
+ margin: 0;
10
+ padding: 0;
11
+
12
+ li {
13
+ display: inline-block;
14
+ width: 100px;
15
+ height: 100px;
16
+ cursor: pointer;
17
+ margin: 0 5px;
18
+ padding: 0;
19
+ vertical-align: top;
20
+
21
+ border: 1px solid #ccc;
22
+ &:hover {
23
+ border: 1px solid red;
24
+ }
25
+
26
+ img {
27
+ max-width: 98px;
28
+ max-height: 98px;
29
+ }
30
+ }
31
+ }
32
+ }
33
+
34
+ .insert-file {
35
+ ul.uploaded-files {
36
+ margin: 5px;
37
+ margin-bottom: 15px;
38
+
39
+ li {
40
+ cursor: pointer;
41
+
42
+ &:hover {
43
+ text-decoration: underline;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ table.uploaded-files {
50
+ img {
51
+ max-width: 100px;
52
+ max-height: 100px;
53
+ }
54
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,126 @@
1
+ module Railswiki
2
+ class ApplicationController < ActionController::Base
3
+ include ApplicationHelper
4
+
5
+ class InvalidRoleError < StandardError; end
6
+
7
+ protect_from_forgery with: :exception
8
+
9
+ helper_method :current_user, :user_can?, :prettify_title, :unprettify_title, :wiki_path
10
+
11
+ private
12
+
13
+ def current_user
14
+ @current_user ||= Railswiki::User.where(id: session[:user_id]).first if session[:user_id]
15
+ end
16
+
17
+ def user_can?(role)
18
+ case role
19
+ when :list_pages
20
+ true
21
+ when :special_pages
22
+ current_user
23
+ when :edit_page, :delete_page, :create_page, :list_pages, :history_page
24
+ current_user && ["admin", "editor"].include?(current_user.role)
25
+ when :list_users
26
+ current_user && ["admin", "editor"].include?(current_user.role)
27
+ when :edit_user, :delete_user
28
+ current_user && ["admin"].include?(current_user.role)
29
+ when :list_histories, :delete_history
30
+ current_user && ["admin", "editor"].include?(current_user.role)
31
+ when :see_page_author
32
+ current_user && ["admin", "editor"].include?(current_user.role)
33
+ when :edit_file, :delete_file, :create_file, :list_files
34
+ current_user && ["admin", "editor"].include?(current_user.role)
35
+ when :list_invites
36
+ current_user && ["admin", "editor"].include?(current_user.role)
37
+ when :delete_invite, :create_invite
38
+ current_user && ["admin"].include?(current_user.role)
39
+ else
40
+ raise InvalidRoleError, "Unknown role #{role}"
41
+ end
42
+ end
43
+
44
+ def require_pages_list_permission
45
+ require_role :list_pages
46
+ end
47
+
48
+ def require_special_pages_permission
49
+ require_role :special_pages
50
+ end
51
+
52
+ def require_page_edit_permission
53
+ require_role :edit_page
54
+ end
55
+
56
+ def require_page_create_permission
57
+ require_role :create_page
58
+ end
59
+
60
+ def require_page_delete_permission
61
+ require_role :delete_page
62
+ end
63
+
64
+ def require_page_history_permission
65
+ require_role :history_page
66
+ end
67
+
68
+ def require_users_list_permission
69
+ require_role :list_users
70
+ end
71
+
72
+ def require_user_edit_permission
73
+ require_role :edit_user
74
+ end
75
+
76
+ def require_user_delete_permission
77
+ require_role :delete_user
78
+ end
79
+
80
+ def require_histories_list_permission
81
+ require_role :list_histories
82
+ end
83
+
84
+ def require_history_delete_permission
85
+ require_role :delete_history
86
+ end
87
+
88
+ def require_files_list_permission
89
+ require_role :list_files
90
+ end
91
+
92
+ def require_file_edit_permission
93
+ require_role :edit_file
94
+ end
95
+
96
+ def require_file_create_permission
97
+ require_role :create_file
98
+ end
99
+
100
+ def require_file_delete_permission
101
+ require_role :delete_file
102
+ end
103
+
104
+ def require_invites_list_permission
105
+ require_role :list_invites
106
+ end
107
+
108
+ def require_invite_create_permission
109
+ require_role :create_invite
110
+ end
111
+
112
+ def require_invite_delete_permission
113
+ require_role :delete_invite
114
+ end
115
+
116
+ def require_role(role)
117
+ begin
118
+ unless user_can?(role)
119
+ raise InvalidRoleError, "You must be logged in to access this section"
120
+ end
121
+ rescue InvalidRoleError => e
122
+ redirect_to sessions_not_authorized_path
123
+ end
124
+ end
125
+ end
126
+ end