railswiki 0.1.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 (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,72 @@
1
+ <% title ["Sitemap"] %>
2
+
3
+ <div class="meta-content">
4
+ <h1>Pages</h1>
5
+
6
+ <table class="list-table">
7
+ <thead>
8
+ <tr>
9
+ <th class="title">Title</th>
10
+ <th class="version">Latest version</th>
11
+ <% if user_can?(:see_page_author) %>
12
+ <th class="author">Author</th>
13
+ <% end %>
14
+ <th class="tools" colspan="3"></th>
15
+ </tr>
16
+ </thead>
17
+
18
+ <tbody>
19
+ <% @pages.order(title: :asc).limit(100).reject { |page| is_special_page?(page) && !user_can?(:special_pages) }.each do |page| %>
20
+ <tr>
21
+ <td class="title"><%= link_to page.title, wiki_path(page) %></td>
22
+ <td class="version">Edited <%= time_ago page.latest_version.created_at %></td>
23
+ <% if user_can?(:see_page_author) %>
24
+ <td class="author">by <%= user_link page.author %></td>
25
+ <% end %>
26
+ <td class="json"><%= link_to "json", wiki_path(page, format: :json) %></td>
27
+ <% if is_special_page?(page) || user_can?(:special_pages) %>
28
+ <td><%= link_to 'Edit', edit_page_path(page) if user_can?(:edit_page) %></td>
29
+ <td><%= link_to 'Destroy', page, method: :delete, data: { confirm: 'Are you sure?' } if user_can?(:delete_page) %></td>
30
+ <% else %>
31
+ <td class="tools" colspan="2"></td>
32
+ <% end %>
33
+ </tr>
34
+ <% end %>
35
+
36
+ <% if @pages.empty? %>
37
+ <tr>
38
+ <td colspan="6">
39
+ <i>no pages found!</i>
40
+ </td>
41
+ </tr>
42
+ <% end %>
43
+ </tbody>
44
+ </table>
45
+
46
+ <% unless @special_pages.empty? || !user_can?(:special_pages) %>
47
+ <h2>Special Pages</h2>
48
+
49
+ <table class="list-table">
50
+ <thead>
51
+ <tr>
52
+ <th class="title">Title</th>
53
+ <th class="tools" colspan="1"></th>
54
+ </tr>
55
+ </thead>
56
+
57
+ <tbody>
58
+ <% @special_pages.each do |page| %>
59
+ <tr>
60
+ <td class="title"><%= link_to page.title, wiki_path(page) %></td>
61
+ <td class="tools"><%= link_to 'Edit', new_page_path(title: page.title) if user_can?(:create_page) %></td>
62
+ </tr>
63
+ <% end %>
64
+ </tbody>
65
+ </table>
66
+ <% end %>
67
+
68
+ <br>
69
+
70
+ <%= link_to 'New Page', new_page_path if user_can?(:create_page) %>
71
+
72
+ </div>
@@ -0,0 +1,7 @@
1
+ <% title ["New page"] %>
2
+
3
+ <h1>New Page</h1>
4
+
5
+ <%= render 'form', page: @page %>
6
+
7
+ <%= link_to 'Back', pages_path %>
@@ -0,0 +1,36 @@
1
+ <% title [@page.title] %>
2
+
3
+ <div class="wiki-content">
4
+ <small class="actions">
5
+ <% if @page.builtin_page? %>
6
+ <%= link_to 'Edit', new_page_path(title: @page.title), class: "edit" if user_can?(:create_page) %>
7
+ <% else %>
8
+ <%= link_to 'History', page_history_path(@page), class: "history" if user_can?(:history_page) %>
9
+ <%= link_to 'Edit', edit_page_path(@page), class: "edit" if user_can?(:edit_page) %>
10
+ <%= link_to ".json", wiki_path(@page, format: :json), class: "json" %>
11
+ <% end %>
12
+ </small>
13
+
14
+ <%= content_tag "h1", class: "title wiki-#{classify_title(@page.title)}" do %>
15
+ <%= @page.title %>
16
+ <% end %>
17
+
18
+ <%= content_tag "div", class: "body wiki-#{classify_title(@page.title)}" do %>
19
+ <%= raw markdown.render @page.content %>
20
+ <% end %>
21
+
22
+ <div class="end-of-content"></div>
23
+
24
+ <p class="information">
25
+ <strong>Edited</strong>
26
+ <% if @page.latest_version %>
27
+ <%= time_ago @page.latest_version.created_at %>
28
+ <% else %>
29
+ <i>never!</i>
30
+ <% end %>
31
+ <% if user_can?(:see_page_author) %>
32
+ <strong>by</strong>
33
+ <%= user_link @page.author %>
34
+ <% end %>
35
+ </p>
36
+ </div>
@@ -0,0 +1,7 @@
1
+ <% title ["Not invited"] %>
2
+
3
+ <div class="wiki-content error">
4
+ <p>
5
+ You must be invited in order to login.
6
+ </p>
7
+ </div>
@@ -0,0 +1,12 @@
1
+ <% title ["Not authorized"] %>
2
+
3
+ <div class="wiki-content error">
4
+ <p>
5
+ You must be <%= link_to "logged in", Rails.application.routes.url_helpers.login_path %> to access this section.
6
+ </p>
7
+
8
+ <p>
9
+ If you are already logged in, you may not have the correct permissions to access this section - you
10
+ may want to try <%= link_to "logging out", logout_path %> instead.
11
+ </p>
12
+ </div>
@@ -0,0 +1,31 @@
1
+ <%= form_for(uploaded_file) do |f| %>
2
+ <% if uploaded_file.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(uploaded_file.errors.count, "error") %> prohibited this uploaded_file from being saved:</h2>
5
+
6
+ <ul>
7
+ <% uploaded_file.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :file %>
16
+ <%= f.file_field :file %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= f.label :user %>
21
+ <%= user_link uploaded_file.user %>
22
+
23
+ <small class="tip">
24
+ That's you!
25
+ </small>
26
+ </div>
27
+
28
+ <div class="actions">
29
+ <%= f.submit %>
30
+ </div>
31
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% if uploaded_file.is_image? %>
2
+ <%= link_to image_tag(uploaded_file.file_url), download_file_path(title: uploaded_file.title) %>
3
+ <% else %>
4
+ <%= link_to uploaded_file.file_identifier, download_file_path(title: uploaded_file.title) %>
5
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% title [@uploaded_file.title, "Edit"] %>
2
+
3
+ <h1>Editing Uploaded File</h1>
4
+
5
+ <%= render 'form', uploaded_file: @uploaded_file %>
6
+
7
+ <%= link_to 'Show', @uploaded_file %> |
8
+ <%= link_to 'Back', uploaded_files_path %>
@@ -0,0 +1,11 @@
1
+ <h2>Insert file</h2>
2
+
3
+ <ul class="uploaded-files">
4
+ <% @uploaded_files.each do |uploaded_file| %>
5
+ <%= content_tag "li", data: {url: download_file_path(title: uploaded_file.title), title: uploaded_file.title} do %>
6
+ <span><%= uploaded_file.title %></span>
7
+ <% end %>
8
+ <% end %>
9
+ </ul>
10
+
11
+ <%= link_to 'Upload new file', new_uploaded_file_path if user_can?(:create_file) %>
@@ -0,0 +1,11 @@
1
+ <h2>Insert image</h2>
2
+
3
+ <ul class="uploaded-images">
4
+ <% @uploaded_files.each do |uploaded_file| %>
5
+ <%= content_tag "li", data: {url: download_file_path(title: uploaded_file.title), title: uploaded_file.title} do %>
6
+ <%= image_tag uploaded_file.file_url %>
7
+ <% end %>
8
+ <% end %>
9
+ </ul>
10
+
11
+ <%= link_to 'Upload new image', new_uploaded_file_path if user_can?(:create_file) %>
@@ -0,0 +1,36 @@
1
+ <% title ["Files"] %>
2
+
3
+ <div class="meta-content">
4
+ <h1>Uploaded Files</h1>
5
+
6
+ <table class="uploaded-files">
7
+ <thead>
8
+ <tr>
9
+ <th>Title</th>
10
+ <th>File</th>
11
+ <th>Edited</th>
12
+ <th>By</th>
13
+ <th colspan="3"></th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @uploaded_files.each do |uploaded_file| %>
19
+ <tr>
20
+ <td><%= link_to uploaded_file.title, uploaded_file %></td>
21
+ <td>
22
+ <%= render "inline", uploaded_file: uploaded_file %>
23
+ </td>
24
+ <td>Edited <%= time_ago uploaded_file.created_at %></td>
25
+ <td>by <%= user_link uploaded_file.user %></td>
26
+ <td><%= link_to 'Edit', edit_uploaded_file_path(uploaded_file) if user_can?(:edit_file) %></td>
27
+ <td><%= link_to 'Destroy', uploaded_file, method: :delete, data: { confirm: 'Are you sure?' } if user_can?(:delete_file) %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+
33
+ <br>
34
+
35
+ <%= link_to 'New Uploaded File', new_uploaded_file_path if user_can?(:create_file) %>
36
+ </div>
@@ -0,0 +1,7 @@
1
+ <% title ["New file"] %>
2
+
3
+ <h1>New Uploaded File</h1>
4
+
5
+ <%= render 'form', uploaded_file: @uploaded_file %>
6
+
7
+ <%= link_to 'Back', uploaded_files_path %>
@@ -0,0 +1,29 @@
1
+ <% title [@uploaded_file.title] %>
2
+
3
+ <h1><%= @uploaded_file.title || "Untitled file" %></h1>
4
+
5
+ <p>
6
+ <strong>File:</strong>
7
+ <%= link_to @uploaded_file.file_identifier, @uploaded_file.file_url %>
8
+ <p>
9
+
10
+ <%= render "inline", uploaded_file: @uploaded_file %>
11
+
12
+ <p>
13
+ <strong>Content type:</strong>
14
+ <%= @uploaded_file.content_type %>
15
+ </p>
16
+
17
+ <p>
18
+ <strong>Edited</strong>
19
+ <%= time_ago @uploaded_file.created_at %>
20
+ <strong>by</strong>
21
+ <% if @uploaded_file.user %>
22
+ <%= link_to @uploaded_file.user.name, @uploaded_file.user %>
23
+ <% else %>
24
+ <i>nobody!</i>
25
+ <% end %>
26
+ </p>
27
+
28
+ <%= link_to 'Edit', edit_uploaded_file_path(@uploaded_file) if user_can?(:edit_file) %>
29
+ <%= link_to 'Back', uploaded_files_path %>
@@ -0,0 +1,29 @@
1
+ <%= form_for(user) do |f| %>
2
+ <% if user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% user.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= f.label :email %>
21
+ <%= f.text_field :email %>
22
+ </div>
23
+
24
+ <%= render("shared/roles", form: f) %>
25
+
26
+ <div class="actions">
27
+ <%= f.submit %>
28
+ </div>
29
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <% title [@user.name, "Edit"] %>
2
+
3
+ <h1>Editing User</h1>
4
+
5
+ <%= render 'form', user: @user %>
6
+
7
+ <%= link_to 'Show', @user %> |
8
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,37 @@
1
+ <% title ["Users"] %>
2
+
3
+ <div class="meta-content">
4
+ <h1>Users</h1>
5
+
6
+ <table class="list-table">
7
+ <thead>
8
+ <tr>
9
+ <th>Image</th>
10
+ <th>Name</th>
11
+ <th>Email</th>
12
+ <th>Role</th>
13
+ <th colspan="4"></th>
14
+ </tr>
15
+ </thead>
16
+
17
+ <tbody>
18
+ <% @users.each do |user| %>
19
+ <tr>
20
+ <td><%= image_tag user.image_url, class: "avatar" %></td>
21
+ <td><%= link_to user.name, user %></td>
22
+ <td><%= mail_to user.email %></td>
23
+ <td><%= user.role %></td>
24
+ <td><%= link_to 'Show', user %></td>
25
+ <td><%= link_to 'Edit', edit_user_path(user) if user_can?(:edit_user) %></td>
26
+ <td><%= link_to "json", user_path(user, format: :json) %></td>
27
+ <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } if user_can?(:delete_user) %></td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+
33
+ <br>
34
+
35
+ <%= link_to "Invited users", invites_path if user_can?(:list_invites) %>
36
+ <%= link_to "Invite new user", new_invite_path if user_can?(:create_invite) %>
37
+ </div>
@@ -0,0 +1,59 @@
1
+ <% title [@user.name] %>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @user.name %>
6
+ <%= link_to "json", user_path(@user, format: :json) %>
7
+ </p>
8
+
9
+ <p>
10
+ <strong>Role:</strong>
11
+ <%= @user.role %>
12
+ </p>
13
+
14
+ <p>
15
+ <strong>Email:</strong>
16
+ <%= mail_to @user.email %>
17
+ </p>
18
+
19
+ <p>
20
+ <strong>Invited by:</strong>
21
+ <%= @user.invite ? link_to(@user.invite.invited_user.name, @user.invite) : "n/a" %>
22
+ </p>
23
+
24
+ <p>
25
+ <strong>Image:</strong>
26
+ <%= image_tag @user.image_url %>
27
+ </p>
28
+
29
+ <p>
30
+ <strong>Provider:</strong>
31
+ <%= @user.provider %>
32
+ </p>
33
+
34
+ <p>
35
+ <strong>Created at</strong>
36
+ <%= time_ago @user.created_at %>
37
+ </p>
38
+
39
+ <p>
40
+ <strong>Last login</strong>
41
+ <%= time_ago @user.last_login %>
42
+ </p>
43
+
44
+ <p>
45
+ <strong>Edits</strong>
46
+ <%= @user.histories.count %>
47
+ </p>
48
+
49
+ <p>
50
+ <strong>Files</strong>
51
+ <%= link_to @user.uploaded_files.count, uploaded_files_path %>
52
+ </p>
53
+
54
+ <h2>Recent edits</h2>
55
+
56
+ <%= render "shared/histories", histories: @user.histories %>
57
+
58
+ <%= link_to 'Edit', edit_user_path(@user) if user_can?(:edit_user) %>
59
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,29 @@
1
+ This is a list of the advanced formatting provided by [railswiki](https://github.com/soundasleep/railswiki). For basic Markdown reference, check out [Markdown Cheatsheet](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet).
2
+
3
+ Generally, for any advanced formatting you should do it in the source/SCSS of your application; otherwise you risk providing a really poor experience to mobile users.
4
+
5
+ ## Templates
6
+
7
+ ```{{template_name}}```
8
+
9
+ Will insert the template [[template_name]].
10
+
11
+ ## Wiki links
12
+
13
+ ```[[link]]``` becomes ```<a href="/link">link</a>```
14
+
15
+ ```[[link|title]]``` becomes ```<a href="/link">title</a>```
16
+
17
+ ```[[link|title|title="home"]]``` becomes ```<a href="/link" title="Home">title</a>```
18
+
19
+ ## Images
20
+
21
+ ```![alt](url.png =100px)``` becomes ```<img src="url.png" alt="alt" max-width="100px">```
22
+
23
+ You can also use `=50x100`, or `=50%`, or `=50%x25%`.
24
+
25
+ ## Arbitrary HTML
26
+
27
+ ```= section``` becomes ```<section>```
28
+
29
+ ```= /section``` becomes ```</section>```