attorney 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +19 -3
- data/app/assets/config/attorney_manifest.js +2 -0
- data/app/assets/javascripts/attorney/application.js +16 -0
- data/app/assets/javascripts/attorney/form_errors.js +13 -0
- data/app/assets/javascripts/attorney/rich_editor.js +19 -0
- data/app/assets/stylesheets/attorney/application.css +16 -0
- data/app/controllers/attorney/admin/documents_controller.rb +49 -0
- data/app/controllers/attorney/application_controller.rb +5 -0
- data/app/controllers/attorney/documents_controller.rb +11 -0
- data/app/helpers/attorney/application_helper.rb +13 -0
- data/app/helpers/attorney/documents_helper.rb +11 -0
- data/app/jobs/attorney/application_job.rb +4 -0
- data/app/mailers/attorney/application_mailer.rb +6 -0
- data/app/models/attorney/application_record.rb +5 -0
- data/app/models/attorney/document.rb +19 -0
- data/app/views/attorney/admin/documents/_form.html.erb +49 -0
- data/app/views/attorney/admin/documents/edit.html.erb +3 -0
- data/app/views/attorney/admin/documents/index.html.erb +37 -0
- data/app/views/attorney/admin/documents/new.html.erb +3 -0
- data/app/views/attorney/admin/documents/show.html.erb +13 -0
- data/app/views/attorney/documents/show.html.erb +1 -0
- data/app/views/layouts/attorney/application.html.erb +25 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20180205173208_create_attorney_documents.rb +13 -0
- data/lib/attorney.rb +12 -2
- data/lib/attorney/engine.rb +14 -0
- data/lib/attorney/version.rb +1 -1
- data/lib/tasks/attorney_tasks.rake +4 -0
- data/spec/controllers/attorney/admin/documents_controller_spec.rb +130 -0
- data/spec/controllers/attorney/documents_controller_spec.rb +26 -0
- data/spec/features/attorney/admin/documents_spec.rb +87 -0
- data/spec/features/attorney/documents_spec.rb +19 -0
- data/spec/helpers/documents_helper_spec.rb +21 -0
- data/spec/lib/attorney_spec.rb +6 -0
- data/spec/models/attorney/document_spec.rb +28 -0
- data/spec/rails_helper.rb +109 -0
- data/spec/spec_helper.rb +96 -0
- data/spec/support/capybara.rb +1 -0
- data/spec/support/dummy/rails5_0/Rakefile +6 -0
- data/spec/support/dummy/rails5_0/app/assets/config/manifest.js +5 -0
- data/spec/support/dummy/rails5_0/app/assets/images/.keep +0 -0
- data/spec/support/dummy/rails5_0/app/assets/javascripts/application.js +13 -0
- data/spec/support/dummy/rails5_0/app/assets/javascripts/cable.js +13 -0
- data/spec/support/dummy/rails5_0/app/assets/javascripts/channels/.keep +0 -0
- data/spec/support/dummy/rails5_0/app/assets/stylesheets/application.css +15 -0
- data/spec/support/dummy/rails5_0/app/channels/application_cable/channel.rb +4 -0
- data/spec/support/dummy/rails5_0/app/channels/application_cable/connection.rb +4 -0
- data/spec/support/dummy/rails5_0/app/controllers/application_controller.rb +3 -0
- data/spec/support/dummy/rails5_0/app/controllers/concerns/.keep +0 -0
- data/spec/support/dummy/rails5_0/app/helpers/application_helper.rb +2 -0
- data/spec/support/dummy/rails5_0/app/jobs/application_job.rb +2 -0
- data/spec/support/dummy/rails5_0/app/mailers/application_mailer.rb +4 -0
- data/spec/support/dummy/rails5_0/app/models/application_record.rb +3 -0
- data/spec/support/dummy/rails5_0/app/models/concerns/.keep +0 -0
- data/spec/support/dummy/rails5_0/app/views/layouts/application.html.erb +15 -0
- data/spec/support/dummy/rails5_0/app/views/layouts/mailer.html.erb +13 -0
- data/spec/support/dummy/rails5_0/app/views/layouts/mailer.text.erb +1 -0
- data/spec/support/dummy/rails5_0/bin/bundle +3 -0
- data/spec/support/dummy/rails5_0/bin/rails +4 -0
- data/spec/support/dummy/rails5_0/bin/rake +4 -0
- data/spec/support/dummy/rails5_0/bin/setup +34 -0
- data/spec/support/dummy/rails5_0/bin/update +29 -0
- data/spec/support/dummy/rails5_0/config.ru +5 -0
- data/spec/support/dummy/rails5_0/config/application.rb +15 -0
- data/spec/support/dummy/rails5_0/config/boot.rb +5 -0
- data/spec/support/dummy/rails5_0/config/cable.yml +9 -0
- data/spec/support/dummy/rails5_0/config/database.yml +25 -0
- data/spec/support/dummy/rails5_0/config/environment.rb +5 -0
- data/spec/support/dummy/rails5_0/config/environments/development.rb +54 -0
- data/spec/support/dummy/rails5_0/config/environments/production.rb +86 -0
- data/spec/support/dummy/rails5_0/config/environments/test.rb +42 -0
- data/spec/support/dummy/rails5_0/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/support/dummy/rails5_0/config/initializers/assets.rb +11 -0
- data/spec/support/dummy/rails5_0/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/support/dummy/rails5_0/config/initializers/cookies_serializer.rb +5 -0
- data/spec/support/dummy/rails5_0/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/support/dummy/rails5_0/config/initializers/inflections.rb +16 -0
- data/spec/support/dummy/rails5_0/config/initializers/mime_types.rb +4 -0
- data/spec/support/dummy/rails5_0/config/initializers/new_framework_defaults.rb +26 -0
- data/spec/support/dummy/rails5_0/config/initializers/session_store.rb +3 -0
- data/spec/support/dummy/rails5_0/config/initializers/wrap_parameters.rb +14 -0
- data/spec/support/dummy/rails5_0/config/locales/en.yml +23 -0
- data/spec/support/dummy/rails5_0/config/puma.rb +47 -0
- data/spec/support/dummy/rails5_0/config/routes.rb +3 -0
- data/spec/support/dummy/rails5_0/config/secrets.yml +22 -0
- data/spec/support/dummy/rails5_0/config/spring.rb +6 -0
- data/spec/support/dummy/rails5_0/db/schema.rb +24 -0
- data/spec/support/dummy/rails5_0/lib/assets/.keep +0 -0
- data/spec/support/dummy/rails5_0/log/.keep +0 -0
- data/spec/support/dummy/rails5_0/public/404.html +67 -0
- data/spec/support/dummy/rails5_0/public/422.html +67 -0
- data/spec/support/dummy/rails5_0/public/500.html +66 -0
- data/spec/support/dummy/rails5_0/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/support/dummy/rails5_0/public/apple-touch-icon.png +0 -0
- data/spec/support/dummy/rails5_0/public/favicon.ico +0 -0
- data/spec/support/dummy/rails5_1/Rakefile +6 -0
- data/spec/support/dummy/rails5_1/app/assets/config/manifest.js +5 -0
- data/spec/support/dummy/rails5_1/app/assets/images/.keep +0 -0
- data/spec/support/dummy/rails5_1/app/assets/javascripts/application.js +13 -0
- data/spec/support/dummy/rails5_1/app/assets/javascripts/cable.js +13 -0
- data/spec/support/dummy/rails5_1/app/assets/javascripts/channels/.keep +0 -0
- data/spec/support/dummy/rails5_1/app/assets/stylesheets/application.css +15 -0
- data/spec/support/dummy/rails5_1/app/channels/application_cable/channel.rb +4 -0
- data/spec/support/dummy/rails5_1/app/channels/application_cable/connection.rb +4 -0
- data/spec/support/dummy/rails5_1/app/controllers/application_controller.rb +4 -0
- data/spec/support/dummy/rails5_1/app/controllers/concerns/.keep +0 -0
- data/spec/support/dummy/rails5_1/app/helpers/application_helper.rb +2 -0
- data/spec/support/dummy/rails5_1/app/jobs/application_job.rb +2 -0
- data/spec/support/dummy/rails5_1/app/mailers/application_mailer.rb +4 -0
- data/spec/support/dummy/rails5_1/app/models/application_record.rb +3 -0
- data/spec/support/dummy/rails5_1/app/models/concerns/.keep +0 -0
- data/spec/support/dummy/rails5_1/app/views/layouts/mailer.html.erb +13 -0
- data/spec/support/dummy/rails5_1/app/views/layouts/mailer.text.erb +1 -0
- data/spec/support/dummy/rails5_1/app/views/layouts/main.html.erb +15 -0
- data/spec/support/dummy/rails5_1/bin/bundle +3 -0
- data/spec/support/dummy/rails5_1/bin/rails +4 -0
- data/spec/support/dummy/rails5_1/bin/rake +4 -0
- data/spec/support/dummy/rails5_1/bin/setup +38 -0
- data/spec/support/dummy/rails5_1/bin/update +29 -0
- data/spec/support/dummy/rails5_1/bin/yarn +11 -0
- data/spec/support/dummy/rails5_1/config.ru +5 -0
- data/spec/support/dummy/rails5_1/config/application.rb +18 -0
- data/spec/support/dummy/rails5_1/config/boot.rb +5 -0
- data/spec/support/dummy/rails5_1/config/cable.yml +10 -0
- data/spec/support/dummy/rails5_1/config/database.yml +25 -0
- data/spec/support/dummy/rails5_1/config/environment.rb +5 -0
- data/spec/support/dummy/rails5_1/config/environments/development.rb +54 -0
- data/spec/support/dummy/rails5_1/config/environments/production.rb +91 -0
- data/spec/support/dummy/rails5_1/config/environments/test.rb +42 -0
- data/spec/support/dummy/rails5_1/config/initializers/application_controller_renderer.rb +8 -0
- data/spec/support/dummy/rails5_1/config/initializers/assets.rb +14 -0
- data/spec/support/dummy/rails5_1/config/initializers/attorney.rb +1 -0
- data/spec/support/dummy/rails5_1/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/support/dummy/rails5_1/config/initializers/cookies_serializer.rb +5 -0
- data/spec/support/dummy/rails5_1/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/support/dummy/rails5_1/config/initializers/inflections.rb +16 -0
- data/spec/support/dummy/rails5_1/config/initializers/mime_types.rb +4 -0
- data/spec/support/dummy/rails5_1/config/initializers/wrap_parameters.rb +14 -0
- data/spec/support/dummy/rails5_1/config/locales/en.yml +33 -0
- data/spec/support/dummy/rails5_1/config/puma.rb +56 -0
- data/spec/support/dummy/rails5_1/config/routes.rb +3 -0
- data/spec/support/dummy/rails5_1/config/secrets.yml +32 -0
- data/spec/support/dummy/rails5_1/config/spring.rb +6 -0
- data/spec/support/dummy/rails5_1/db/schema.rb +24 -0
- data/spec/support/dummy/rails5_1/lib/assets/.keep +0 -0
- data/spec/support/dummy/rails5_1/log/.keep +0 -0
- data/spec/support/dummy/rails5_1/package.json +5 -0
- data/spec/support/dummy/rails5_1/public/404.html +67 -0
- data/spec/support/dummy/rails5_1/public/422.html +67 -0
- data/spec/support/dummy/rails5_1/public/500.html +66 -0
- data/spec/support/dummy/rails5_1/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/support/dummy/rails5_1/public/apple-touch-icon.png +0 -0
- data/spec/support/dummy/rails5_1/public/favicon.ico +0 -0
- data/spec/support/helpers/auth.rb +12 -0
- data/spec/support/shoulda_matchers.rb +8 -0
- data/vendor/assets/javascripts/attorney/bootstrap.bundle.min.js +7 -0
- data/vendor/assets/stylesheets/attorney/bootstrap.min.css +7 -0
- metadata +401 -28
- data/.gitignore +0 -13
- data/.rspec +0 -3
- data/.travis.yml +0 -5
- data/Gemfile +0 -6
- data/LICENSE.txt +0 -21
- data/README.md +0 -39
- data/attorney.gemspec +0 -25
- data/bin/console +0 -14
- data/bin/setup +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9d7311db63d4a9db95408cad0cbb7ef07d05f73c
|
4
|
+
data.tar.gz: a7ccf0d951276dcf307aba2a43ef5a1c0980b5da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ced4ffaa41132d1c5ce3eb4604ec492e180d85d404c1e9b134c3b55df39ddf025f646ca5347dc2f34ae2fc604519601756ea46fbfe8d3d81346dd75b0bb1e7
|
7
|
+
data.tar.gz: 2be022c74b3995ab387e37ecd74adfe73ffd2df28a6061fa83952b2c9503d90f25dbfbf9ed184200ffaa11758c0353eb2643b112f45c8d6705d3c6eb319307e8
|
data/Rakefile
CHANGED
@@ -1,6 +1,22 @@
|
|
1
|
-
|
2
|
-
require
|
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
|
-
|
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,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,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,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,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,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>
|
data/config/routes.rb
ADDED
@@ -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
|
data/lib/attorney.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
-
require
|
1
|
+
require 'attorney/engine'
|
2
|
+
require 'jquery-rails'
|
2
3
|
|
3
4
|
module Attorney
|
4
|
-
|
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
|