attorney 0.0.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (168) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +19 -3
  3. data/app/assets/config/attorney_manifest.js +2 -0
  4. data/app/assets/javascripts/attorney/application.js +16 -0
  5. data/app/assets/javascripts/attorney/form_errors.js +13 -0
  6. data/app/assets/javascripts/attorney/rich_editor.js +19 -0
  7. data/app/assets/stylesheets/attorney/application.css +16 -0
  8. data/app/controllers/attorney/admin/documents_controller.rb +49 -0
  9. data/app/controllers/attorney/application_controller.rb +5 -0
  10. data/app/controllers/attorney/documents_controller.rb +11 -0
  11. data/app/helpers/attorney/application_helper.rb +13 -0
  12. data/app/helpers/attorney/documents_helper.rb +11 -0
  13. data/app/jobs/attorney/application_job.rb +4 -0
  14. data/app/mailers/attorney/application_mailer.rb +6 -0
  15. data/app/models/attorney/application_record.rb +5 -0
  16. data/app/models/attorney/document.rb +19 -0
  17. data/app/views/attorney/admin/documents/_form.html.erb +49 -0
  18. data/app/views/attorney/admin/documents/edit.html.erb +3 -0
  19. data/app/views/attorney/admin/documents/index.html.erb +37 -0
  20. data/app/views/attorney/admin/documents/new.html.erb +3 -0
  21. data/app/views/attorney/admin/documents/show.html.erb +13 -0
  22. data/app/views/attorney/documents/show.html.erb +1 -0
  23. data/app/views/layouts/attorney/application.html.erb +25 -0
  24. data/config/routes.rb +9 -0
  25. data/db/migrate/20180205173208_create_attorney_documents.rb +13 -0
  26. data/lib/attorney.rb +12 -2
  27. data/lib/attorney/engine.rb +14 -0
  28. data/lib/attorney/version.rb +1 -1
  29. data/lib/tasks/attorney_tasks.rake +4 -0
  30. data/spec/controllers/attorney/admin/documents_controller_spec.rb +130 -0
  31. data/spec/controllers/attorney/documents_controller_spec.rb +26 -0
  32. data/spec/features/attorney/admin/documents_spec.rb +87 -0
  33. data/spec/features/attorney/documents_spec.rb +19 -0
  34. data/spec/helpers/documents_helper_spec.rb +21 -0
  35. data/spec/lib/attorney_spec.rb +6 -0
  36. data/spec/models/attorney/document_spec.rb +28 -0
  37. data/spec/rails_helper.rb +109 -0
  38. data/spec/spec_helper.rb +96 -0
  39. data/spec/support/capybara.rb +1 -0
  40. data/spec/support/dummy/rails5_0/Rakefile +6 -0
  41. data/spec/support/dummy/rails5_0/app/assets/config/manifest.js +5 -0
  42. data/spec/support/dummy/rails5_0/app/assets/images/.keep +0 -0
  43. data/spec/support/dummy/rails5_0/app/assets/javascripts/application.js +13 -0
  44. data/spec/support/dummy/rails5_0/app/assets/javascripts/cable.js +13 -0
  45. data/spec/support/dummy/rails5_0/app/assets/javascripts/channels/.keep +0 -0
  46. data/spec/support/dummy/rails5_0/app/assets/stylesheets/application.css +15 -0
  47. data/spec/support/dummy/rails5_0/app/channels/application_cable/channel.rb +4 -0
  48. data/spec/support/dummy/rails5_0/app/channels/application_cable/connection.rb +4 -0
  49. data/spec/support/dummy/rails5_0/app/controllers/application_controller.rb +3 -0
  50. data/spec/support/dummy/rails5_0/app/controllers/concerns/.keep +0 -0
  51. data/spec/support/dummy/rails5_0/app/helpers/application_helper.rb +2 -0
  52. data/spec/support/dummy/rails5_0/app/jobs/application_job.rb +2 -0
  53. data/spec/support/dummy/rails5_0/app/mailers/application_mailer.rb +4 -0
  54. data/spec/support/dummy/rails5_0/app/models/application_record.rb +3 -0
  55. data/spec/support/dummy/rails5_0/app/models/concerns/.keep +0 -0
  56. data/spec/support/dummy/rails5_0/app/views/layouts/application.html.erb +15 -0
  57. data/spec/support/dummy/rails5_0/app/views/layouts/mailer.html.erb +13 -0
  58. data/spec/support/dummy/rails5_0/app/views/layouts/mailer.text.erb +1 -0
  59. data/spec/support/dummy/rails5_0/bin/bundle +3 -0
  60. data/spec/support/dummy/rails5_0/bin/rails +4 -0
  61. data/spec/support/dummy/rails5_0/bin/rake +4 -0
  62. data/spec/support/dummy/rails5_0/bin/setup +34 -0
  63. data/spec/support/dummy/rails5_0/bin/update +29 -0
  64. data/spec/support/dummy/rails5_0/config.ru +5 -0
  65. data/spec/support/dummy/rails5_0/config/application.rb +15 -0
  66. data/spec/support/dummy/rails5_0/config/boot.rb +5 -0
  67. data/spec/support/dummy/rails5_0/config/cable.yml +9 -0
  68. data/spec/support/dummy/rails5_0/config/database.yml +25 -0
  69. data/spec/support/dummy/rails5_0/config/environment.rb +5 -0
  70. data/spec/support/dummy/rails5_0/config/environments/development.rb +54 -0
  71. data/spec/support/dummy/rails5_0/config/environments/production.rb +86 -0
  72. data/spec/support/dummy/rails5_0/config/environments/test.rb +42 -0
  73. data/spec/support/dummy/rails5_0/config/initializers/application_controller_renderer.rb +8 -0
  74. data/spec/support/dummy/rails5_0/config/initializers/assets.rb +11 -0
  75. data/spec/support/dummy/rails5_0/config/initializers/backtrace_silencers.rb +7 -0
  76. data/spec/support/dummy/rails5_0/config/initializers/cookies_serializer.rb +5 -0
  77. data/spec/support/dummy/rails5_0/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/spec/support/dummy/rails5_0/config/initializers/inflections.rb +16 -0
  79. data/spec/support/dummy/rails5_0/config/initializers/mime_types.rb +4 -0
  80. data/spec/support/dummy/rails5_0/config/initializers/new_framework_defaults.rb +26 -0
  81. data/spec/support/dummy/rails5_0/config/initializers/session_store.rb +3 -0
  82. data/spec/support/dummy/rails5_0/config/initializers/wrap_parameters.rb +14 -0
  83. data/spec/support/dummy/rails5_0/config/locales/en.yml +23 -0
  84. data/spec/support/dummy/rails5_0/config/puma.rb +47 -0
  85. data/spec/support/dummy/rails5_0/config/routes.rb +3 -0
  86. data/spec/support/dummy/rails5_0/config/secrets.yml +22 -0
  87. data/spec/support/dummy/rails5_0/config/spring.rb +6 -0
  88. data/spec/support/dummy/rails5_0/db/schema.rb +24 -0
  89. data/spec/support/dummy/rails5_0/lib/assets/.keep +0 -0
  90. data/spec/support/dummy/rails5_0/log/.keep +0 -0
  91. data/spec/support/dummy/rails5_0/public/404.html +67 -0
  92. data/spec/support/dummy/rails5_0/public/422.html +67 -0
  93. data/spec/support/dummy/rails5_0/public/500.html +66 -0
  94. data/spec/support/dummy/rails5_0/public/apple-touch-icon-precomposed.png +0 -0
  95. data/spec/support/dummy/rails5_0/public/apple-touch-icon.png +0 -0
  96. data/spec/support/dummy/rails5_0/public/favicon.ico +0 -0
  97. data/spec/support/dummy/rails5_1/Rakefile +6 -0
  98. data/spec/support/dummy/rails5_1/app/assets/config/manifest.js +5 -0
  99. data/spec/support/dummy/rails5_1/app/assets/images/.keep +0 -0
  100. data/spec/support/dummy/rails5_1/app/assets/javascripts/application.js +13 -0
  101. data/spec/support/dummy/rails5_1/app/assets/javascripts/cable.js +13 -0
  102. data/spec/support/dummy/rails5_1/app/assets/javascripts/channels/.keep +0 -0
  103. data/spec/support/dummy/rails5_1/app/assets/stylesheets/application.css +15 -0
  104. data/spec/support/dummy/rails5_1/app/channels/application_cable/channel.rb +4 -0
  105. data/spec/support/dummy/rails5_1/app/channels/application_cable/connection.rb +4 -0
  106. data/spec/support/dummy/rails5_1/app/controllers/application_controller.rb +4 -0
  107. data/spec/support/dummy/rails5_1/app/controllers/concerns/.keep +0 -0
  108. data/spec/support/dummy/rails5_1/app/helpers/application_helper.rb +2 -0
  109. data/spec/support/dummy/rails5_1/app/jobs/application_job.rb +2 -0
  110. data/spec/support/dummy/rails5_1/app/mailers/application_mailer.rb +4 -0
  111. data/spec/support/dummy/rails5_1/app/models/application_record.rb +3 -0
  112. data/spec/support/dummy/rails5_1/app/models/concerns/.keep +0 -0
  113. data/spec/support/dummy/rails5_1/app/views/layouts/mailer.html.erb +13 -0
  114. data/spec/support/dummy/rails5_1/app/views/layouts/mailer.text.erb +1 -0
  115. data/spec/support/dummy/rails5_1/app/views/layouts/main.html.erb +15 -0
  116. data/spec/support/dummy/rails5_1/bin/bundle +3 -0
  117. data/spec/support/dummy/rails5_1/bin/rails +4 -0
  118. data/spec/support/dummy/rails5_1/bin/rake +4 -0
  119. data/spec/support/dummy/rails5_1/bin/setup +38 -0
  120. data/spec/support/dummy/rails5_1/bin/update +29 -0
  121. data/spec/support/dummy/rails5_1/bin/yarn +11 -0
  122. data/spec/support/dummy/rails5_1/config.ru +5 -0
  123. data/spec/support/dummy/rails5_1/config/application.rb +18 -0
  124. data/spec/support/dummy/rails5_1/config/boot.rb +5 -0
  125. data/spec/support/dummy/rails5_1/config/cable.yml +10 -0
  126. data/spec/support/dummy/rails5_1/config/database.yml +25 -0
  127. data/spec/support/dummy/rails5_1/config/environment.rb +5 -0
  128. data/spec/support/dummy/rails5_1/config/environments/development.rb +54 -0
  129. data/spec/support/dummy/rails5_1/config/environments/production.rb +91 -0
  130. data/spec/support/dummy/rails5_1/config/environments/test.rb +42 -0
  131. data/spec/support/dummy/rails5_1/config/initializers/application_controller_renderer.rb +8 -0
  132. data/spec/support/dummy/rails5_1/config/initializers/assets.rb +14 -0
  133. data/spec/support/dummy/rails5_1/config/initializers/attorney.rb +1 -0
  134. data/spec/support/dummy/rails5_1/config/initializers/backtrace_silencers.rb +7 -0
  135. data/spec/support/dummy/rails5_1/config/initializers/cookies_serializer.rb +5 -0
  136. data/spec/support/dummy/rails5_1/config/initializers/filter_parameter_logging.rb +4 -0
  137. data/spec/support/dummy/rails5_1/config/initializers/inflections.rb +16 -0
  138. data/spec/support/dummy/rails5_1/config/initializers/mime_types.rb +4 -0
  139. data/spec/support/dummy/rails5_1/config/initializers/wrap_parameters.rb +14 -0
  140. data/spec/support/dummy/rails5_1/config/locales/en.yml +33 -0
  141. data/spec/support/dummy/rails5_1/config/puma.rb +56 -0
  142. data/spec/support/dummy/rails5_1/config/routes.rb +3 -0
  143. data/spec/support/dummy/rails5_1/config/secrets.yml +32 -0
  144. data/spec/support/dummy/rails5_1/config/spring.rb +6 -0
  145. data/spec/support/dummy/rails5_1/db/schema.rb +24 -0
  146. data/spec/support/dummy/rails5_1/lib/assets/.keep +0 -0
  147. data/spec/support/dummy/rails5_1/log/.keep +0 -0
  148. data/spec/support/dummy/rails5_1/package.json +5 -0
  149. data/spec/support/dummy/rails5_1/public/404.html +67 -0
  150. data/spec/support/dummy/rails5_1/public/422.html +67 -0
  151. data/spec/support/dummy/rails5_1/public/500.html +66 -0
  152. data/spec/support/dummy/rails5_1/public/apple-touch-icon-precomposed.png +0 -0
  153. data/spec/support/dummy/rails5_1/public/apple-touch-icon.png +0 -0
  154. data/spec/support/dummy/rails5_1/public/favicon.ico +0 -0
  155. data/spec/support/helpers/auth.rb +12 -0
  156. data/spec/support/shoulda_matchers.rb +8 -0
  157. data/vendor/assets/javascripts/attorney/bootstrap.bundle.min.js +7 -0
  158. data/vendor/assets/stylesheets/attorney/bootstrap.min.css +7 -0
  159. metadata +401 -28
  160. data/.gitignore +0 -13
  161. data/.rspec +0 -3
  162. data/.travis.yml +0 -5
  163. data/Gemfile +0 -6
  164. data/LICENSE.txt +0 -21
  165. data/README.md +0 -39
  166. data/attorney.gemspec +0 -25
  167. data/bin/console +0 -14
  168. data/bin/setup +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 9bdb86641ec32c41a8a5698b8b49890316ee6f9b1a72e1a025edb0ac96ece410
4
- data.tar.gz: 2056fcb8c9b5f26003f6ff748a3784a5daac57e9dc4913f0ca8899d3d52b643e
2
+ SHA1:
3
+ metadata.gz: 9d7311db63d4a9db95408cad0cbb7ef07d05f73c
4
+ data.tar.gz: a7ccf0d951276dcf307aba2a43ef5a1c0980b5da
5
5
  SHA512:
6
- metadata.gz: b4cca6db469589296740232c69750a2a1c1cf089068c2a200fcb4d19d3ffbca4dd5bc9c38fc839bd522ad6eed2d163533fcbf430277193cbda540451098e731e
7
- data.tar.gz: 9a7a03e1fbd70b7009238050f6977b74182cc24d9ffd9ce6dc6460290b9b4c36b25e68df983cdc1c7308519d05041794a9e4fd54d4094042803d60b1a6106bbe
6
+ metadata.gz: c3ced4ffaa41132d1c5ce3eb4604ec492e180d85d404c1e9b134c3b55df39ddf025f646ca5347dc2f34ae2fc604519601756ea46fbfe8d3d81346dd75b0bb1e7
7
+ data.tar.gz: 2be022c74b3995ab387e37ecd74adfe73ffd2df28a6061fa83952b2c9503d90f25dbfbf9ed184200ffaa11758c0353eb2643b112f45c8d6705d3c6eb319307e8
data/Rakefile CHANGED
@@ -1,6 +1,22 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
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
+ require 'rspec/core/rake_task'
3
7
 
4
8
  RSpec::Core::RakeTask.new(:spec)
9
+ task default: :spec
10
+ task test: :spec
5
11
 
6
- task :default => :spec
12
+ require 'rails'
13
+ if Rails.version.start_with?('5.0')
14
+ APP_RAKEFILE = File.expand_path('../spec/support/dummy/rails5_0/Rakefile', __FILE__)
15
+ elsif Rails.version.start_with?('5.1')
16
+ APP_RAKEFILE = File.expand_path('../spec/support/dummy/rails5_1/Rakefile', __FILE__)
17
+ end
18
+
19
+
20
+ load 'rails/tasks/engine.rake'
21
+ load 'rails/tasks/statistics.rake'
22
+ require 'bundler/gem_tasks'
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/attorney .js
2
+ //= link_directory ../stylesheets/attorney .css
@@ -0,0 +1,16 @@
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 jquery
14
+ //= require jquery_ujs
15
+ //= require 'attorney/bootstrap.bundle.min'
16
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ (function() {
2
+ var FormErrors = function() {
3
+ this.render = function() {
4
+ form().find('.field_with_errors input').addClass('is-invalid');
5
+ };
6
+
7
+ var form = function() {
8
+ return $("form[data-style-form-errors='true']");
9
+ };
10
+ };
11
+
12
+ $(document).ready(function() { new FormErrors().render() });
13
+ })();
@@ -0,0 +1,19 @@
1
+ (function() {
2
+ var RichEditor = function() {
3
+ this.show = function() {
4
+ renderEditors(findTextAreas());
5
+ };
6
+
7
+ var findTextAreas = function() {
8
+ return $("textarea[data-rich-editor='true']")
9
+ };
10
+
11
+ var renderEditors = function($inputFields) {
12
+ $inputFields.each(function(index, inputField) {
13
+ CKEDITOR.replace(inputField.getAttribute("id"));
14
+ });
15
+ };
16
+ };
17
+
18
+ $(document).ready(function() { new RichEditor().show() });
19
+ })();
@@ -0,0 +1,16 @@
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 'attorney/bootstrap.min'
14
+ *= require_tree .
15
+ *= require_self
16
+ */
@@ -0,0 +1,49 @@
1
+ require_dependency "attorney/application_controller"
2
+
3
+ module Attorney
4
+ class Admin::DocumentsController < ApplicationController
5
+ http_basic_authenticate_with name: Attorney.http_auth[:name], password: Attorney.http_auth[:password]
6
+ before_action :set_document, only: [:show, :edit, :update, :destroy]
7
+
8
+ def index
9
+ @documents = Document.all
10
+ end
11
+
12
+ def new
13
+ @document = Document.new
14
+ end
15
+
16
+ def create
17
+ @document = Document.new(document_params)
18
+
19
+ if @document.save
20
+ redirect_to admin_document_url(@document), notice: 'Document was successfully created.'
21
+ else
22
+ render :new
23
+ end
24
+ end
25
+
26
+ def update
27
+ if @document.update(document_params)
28
+ redirect_to admin_document_url(@document), notice: 'Document was successfully updated.'
29
+ else
30
+ render :edit
31
+ end
32
+ end
33
+
34
+ def destroy
35
+ @document.destroy
36
+ redirect_to admin_documents_url, notice: 'Document was successfully destroyed.'
37
+ end
38
+
39
+ private
40
+
41
+ def set_document
42
+ @document = Document.find(params[:id])
43
+ end
44
+
45
+ def document_params
46
+ params.require(:document).permit(:slug, :published, :content)
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,5 @@
1
+ module Attorney
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,11 @@
1
+ require_dependency 'attorney/application_controller'
2
+
3
+ module Attorney
4
+ class DocumentsController < ApplicationController
5
+ layout Attorney.application_layout
6
+
7
+ def show
8
+ @document = Document.published.find_by_slug!(params[:slug])
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module Attorney
2
+ module ApplicationHelper
3
+ def attorney_mounted_path
4
+ Rails.application.routes.named_routes[:attorney].format(nil)
5
+ end
6
+
7
+ def show_notice(notice)
8
+ if notice.present?
9
+ content_tag :p, notice, id: 'notice', class: 'alert alert-primary', role: 'alert'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Attorney
2
+ module DocumentsHelper
3
+ def published_badge(document)
4
+ if document.published?
5
+ content_tag :span, 'Published', class: 'badge badge-success'
6
+ else
7
+ content_tag :span, 'Not published', class: 'badge badge-secondary'
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module Attorney
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Attorney
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Attorney
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ module Attorney
2
+ class Document < ApplicationRecord
3
+ scope :published, -> { where(published: true) }
4
+
5
+ validates :slug, uniqueness: true
6
+ validates :slug, presence: true
7
+ validate :slug_format_is_valid
8
+
9
+ private
10
+
11
+ def slug_format_is_valid
12
+ return if slug.nil?
13
+
14
+ unless slug.parameterize == slug
15
+ errors.add(:slug, "Slug format is invalid, try \"#{slug.parameterize}\" instead.")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,49 @@
1
+ <%= form_for([:admin, document], data: { style_form_errors: true }) do |form| %>
2
+ <% if document.errors.any? %>
3
+ <div class="alert alert-danger" role="alert">
4
+ <h4><%= pluralize(document.errors.count, 'error') %> prohibited this document from being saved:</h4>
5
+
6
+ <ul>
7
+ <% document.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="form-group row">
15
+ <div class="col-2 ">
16
+ <%= form.label :slug, class: 'col-form-label' %>
17
+ </div>
18
+ <div class="col-10">
19
+ <%= form.text_field :slug, class: 'form-control', placeholder: 'terms-and-conditions' %>
20
+ <small class="form-text text-muted"><%= "Slugs are used to create your documents url. For example: https://www.website.com#{attorney_mounted_path}/terms-and-conditions" %></small>
21
+ </div>
22
+ </div>
23
+
24
+ <br>
25
+ <div class="form-group row">
26
+ <div class="col-2 ">
27
+ <%= form.label :published, 'Publish', class: 'col-form-label' %>
28
+ </div>
29
+ <div class="col-10">
30
+ <%= form.check_box :published %>
31
+ <small class="form-text text-muted"><%= "The document won't be visible until you publish it" %></small>
32
+ </div>
33
+ </div>
34
+
35
+ <br>
36
+ <div class="form-group row">
37
+ <%= form.label :content, class: 'col-2 col-form-label' %>
38
+ <div class="col-10">
39
+ <%= form.text_area :content, class: 'form-control', data: { 'rich-editor' => true } %>
40
+ </div>
41
+ </div>
42
+
43
+ <div class="actions">
44
+ <%= form.submit class: 'btn btn-primary' %>
45
+ <%= link_to 'Cancel', admin_documents_path, class: 'btn btn-secondary' %>
46
+ </div>
47
+ <% end %>
48
+
49
+ <%= javascript_include_tag 'https://cdn.ckeditor.com/4.8.0/standard/ckeditor.js' %>
@@ -0,0 +1,3 @@
1
+ <h1>Editing Document</h1>
2
+ <br>
3
+ <%= render 'form', document: @document %>
@@ -0,0 +1,37 @@
1
+ <h1>Documents list</h1>
2
+ <br>
3
+ <% if @documents.any? %>
4
+ <table class="table table-striped">
5
+ <thead>
6
+ <tr>
7
+ <th scope="col" width="20%">Slug</th>
8
+ <th scope="col">Published?</th>
9
+ <th scope="col">Content</th>
10
+ <th scope="col" width="10%" class="text-center" colspan="2"></th>
11
+ </tr>
12
+ </thead>
13
+
14
+ <tbody>
15
+ <% @documents.each do |document| %>
16
+ <tr>
17
+ <td scope="row"><%= link_to document.slug, admin_document_path(document), class: 'text-secondary' %></td>
18
+ <td><%= published_badge(document) %></td>
19
+ <td><%= document.content.truncate(200) %></td>
20
+ <td><%= link_to 'Edit', edit_admin_document_path(document), class: 'text-primary' %></td>
21
+ <td><%= link_to 'Destroy', admin_document_path(document), class: 'text-danger', method: :delete, data: { confirm: 'Are you sure?' } %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+
27
+ <br>
28
+ <%= link_to 'New Document', new_admin_document_path, class: 'btn btn-primary' %>
29
+ <% else %>
30
+ <div class="card text-center">
31
+ <div class="card-body">
32
+ <h5 class="card-title">We don't have anything to show yet :(</h5>
33
+ <p class="card-text">Looks like you haven't created any documents. Try creating the first one by clicking the button below!</p>
34
+ <%= link_to 'New Document', new_admin_document_path, class: 'btn btn-primary' %>
35
+ </div>
36
+ </div>
37
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <h1>New Document</h1>
2
+ <br>
3
+ <%= render 'form', document: @document %>
@@ -0,0 +1,13 @@
1
+ <h1><%= "#{attorney_mounted_path}/#{@document.slug}" %></h1>
2
+ <br>
3
+ <h3><%= published_badge(@document) %></h3>
4
+ <br>
5
+
6
+ <div class="card">
7
+ <div class="card-body">
8
+ <%= @document.content.html_safe %>
9
+ </div>
10
+ </div>
11
+
12
+ <br>
13
+ <%= link_to 'Back', admin_documents_path, class: 'text-secondary' %>
@@ -0,0 +1 @@
1
+ <%= @document.content.html_safe %>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Attorney</title>
5
+
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8
+ <%= stylesheet_link_tag 'attorney/application', media: 'all' %>
9
+ <%= javascript_include_tag 'attorney/application' %>
10
+ <%= csrf_meta_tags %>
11
+ </head>
12
+ <body>
13
+ <nav class="navbar navbar-dark bg-dark">
14
+ <div class="container">
15
+ <%= link_to 'Documents Admin', admin_documents_path, class: 'navbar-brand' %>
16
+ </div>
17
+ </nav>
18
+
19
+ <div class="container">
20
+ <br>
21
+ <%= show_notice(notice) %>
22
+ <%= yield %>
23
+ </div>
24
+ </body>
25
+ </html>
@@ -0,0 +1,9 @@
1
+ Attorney::Engine.routes.draw do
2
+ root to: 'admin/documents#index'
3
+
4
+ namespace :admin do
5
+ resources :documents
6
+ end
7
+
8
+ get '/:slug', to: 'documents#show', as: :document
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateAttorneyDocuments < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :attorney_documents do |t|
4
+ t.string :slug, null: false
5
+ t.boolean :published, null: false, default: false
6
+ t.text :content
7
+
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :attorney_documents, :slug, unique: true
12
+ end
13
+ end
@@ -1,5 +1,15 @@
1
- require "attorney/version"
1
+ require 'attorney/engine'
2
+ require 'jquery-rails'
2
3
 
3
4
  module Attorney
4
- # Your code goes here...
5
+ mattr_accessor :application_layout do
6
+ 'application'
7
+ end
8
+
9
+ def self.http_auth
10
+ {
11
+ name: ENV['ATTORNEY_HTTP_AUTH_NAME'] || 'attorney',
12
+ password: ENV['ATTORNEY_HTTP_AUTH_PASSWORD'] || 'secret'
13
+ }
14
+ end
5
15
  end
@@ -0,0 +1,14 @@
1
+ module Attorney
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Attorney
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ end
8
+
9
+ initializer 'attorney.assets.precompile' do |app|
10
+ app.config.assets.paths << Rails.root.join('vendor', 'assets', 'javascripts')
11
+ app.config.assets.paths << Rails.root.join('vendor', 'assets', 'stylesheets')
12
+ end
13
+ end
14
+ end