ucpengine 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/ucpengine/application.js +13 -0
  6. data/app/assets/javascripts/ucpengine/entries.js +46 -0
  7. data/app/assets/javascripts/ucpengine/live-preview.js +0 -0
  8. data/app/assets/stylesheets/ucpengine/application.scss +61 -0
  9. data/app/assets/stylesheets/ucpengine/entries.css +4 -0
  10. data/app/controllers/ucpengine/application_controller.rb +41 -0
  11. data/app/controllers/ucpengine/dashboard_controller.rb +8 -0
  12. data/app/controllers/ucpengine/entries_controller.rb +62 -0
  13. data/app/controllers/ucpengine/previews_controller.rb +9 -0
  14. data/app/helpers/ucpengine/application_helper.rb +4 -0
  15. data/app/helpers/ucpengine/entries_helper.rb +4 -0
  16. data/app/helpers/ucpengine/markdown_helper.rb +27 -0
  17. data/app/models/ucpengine/concerns/searchable.rb +34 -0
  18. data/app/models/ucpengine/entry.rb +23 -0
  19. data/app/models/ucpengine/entry_search_data.rb +19 -0
  20. data/app/views/layouts/ucpengine/application.html.erb +39 -0
  21. data/app/views/ucpengine/dashboard/index.html.erb +3 -0
  22. data/app/views/ucpengine/entries/_form.html.erb +25 -0
  23. data/app/views/ucpengine/entries/edit.html.erb +6 -0
  24. data/app/views/ucpengine/entries/index.html.erb +15 -0
  25. data/app/views/ucpengine/entries/new.html.erb +7 -0
  26. data/app/views/ucpengine/entries/show.html.erb +21 -0
  27. data/app/views/ucpengine/previews/shot.html.erb +1 -0
  28. data/config/locales/simple_form.en.yml +31 -0
  29. data/config/routes.rb +9 -0
  30. data/db/migrate/20161028170915_create_ucpengine_entries.rb +13 -0
  31. data/db/migrate/20161028204606_create_ucpengine_entry_search_data.rb +14 -0
  32. data/db/migrate/20161102192430_add_slug_to_ucpengine_entries.rb +5 -0
  33. data/db/migrate/20161102192856_add_published_at_to_ucpengine_entries.rb +5 -0
  34. data/lib/tasks/ucpengine_tasks.rake +4 -0
  35. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  36. data/lib/ucpengine/configuration.rb +29 -0
  37. data/lib/ucpengine/engine.rb +10 -0
  38. data/lib/ucpengine/simple_form_config.rb +21 -0
  39. data/lib/ucpengine/version.rb +3 -0
  40. data/lib/ucpengine.rb +6 -0
  41. data/test/controllers/ucpengine/entries_controller_test.rb +13 -0
  42. data/test/dummy/README.rdoc +28 -0
  43. data/test/dummy/Rakefile +6 -0
  44. data/test/dummy/app/assets/javascripts/application.js +13 -0
  45. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  46. data/test/dummy/app/controllers/application_controller.rb +5 -0
  47. data/test/dummy/app/helpers/application_helper.rb +2 -0
  48. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  49. data/test/dummy/bin/bundle +3 -0
  50. data/test/dummy/bin/rails +4 -0
  51. data/test/dummy/bin/rake +4 -0
  52. data/test/dummy/bin/setup +29 -0
  53. data/test/dummy/config/application.rb +26 -0
  54. data/test/dummy/config/boot.rb +5 -0
  55. data/test/dummy/config/database.yml +85 -0
  56. data/test/dummy/config/environment.rb +5 -0
  57. data/test/dummy/config/environments/development.rb +41 -0
  58. data/test/dummy/config/environments/production.rb +79 -0
  59. data/test/dummy/config/environments/test.rb +42 -0
  60. data/test/dummy/config/initializers/assets.rb +11 -0
  61. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  62. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  63. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  64. data/test/dummy/config/initializers/inflections.rb +16 -0
  65. data/test/dummy/config/initializers/mime_types.rb +4 -0
  66. data/test/dummy/config/initializers/session_store.rb +3 -0
  67. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  68. data/test/dummy/config/locales/en.yml +23 -0
  69. data/test/dummy/config/routes.rb +4 -0
  70. data/test/dummy/config/secrets.yml +22 -0
  71. data/test/dummy/config.ru +4 -0
  72. data/test/dummy/public/404.html +67 -0
  73. data/test/dummy/public/422.html +67 -0
  74. data/test/dummy/public/500.html +66 -0
  75. data/test/dummy/public/favicon.ico +0 -0
  76. data/test/fixtures/ucpengine/entries.yml +11 -0
  77. data/test/fixtures/ucpengine/entry_search_data.yml +13 -0
  78. data/test/integration/navigation_test.rb +8 -0
  79. data/test/models/ucpengine/entry_search_data_test.rb +9 -0
  80. data/test/models/ucpengine/entry_test.rb +9 -0
  81. data/test/test_helper.rb +21 -0
  82. data/test/ucpengine_test.rb +7 -0
  83. metadata +335 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: af78e3a3b3190e96e4629eca15575fb7263dc151
4
+ data.tar.gz: 4a527b419de29ca230e321f7d1cb992381a225e1
5
+ SHA512:
6
+ metadata.gz: 07f8239672326faa5914e19eea4e5a9ce80eef7d6af43b3f0d89fda1dd60731b9ce29e7287faf391eaead8b9d7bb1abc36d3562a447ffa3eb8cc033e03226203
7
+ data.tar.gz: 0dc77ceaee151835a71cdf6785387ffd1864e2d361efa22f12c9d1790c0ced54552ad86942b66294fdb51e8d663cff46b2ea01d8eb817795a0ba40007fc9fede
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 johnvehr
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.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Ucpengine
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
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 = 'Ucpengine'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -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.
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,46 @@
1
+
2
+ var Ucpengine = Ucpengine || {};
3
+
4
+ Ucpengine.Utils = {
5
+ // Source: https://remysharp.com/2010/07/21/throttling-function-calls
6
+ debounce: function(fn, delay) {
7
+ var timer = null;
8
+ return function () {
9
+ var context = this, args = arguments;
10
+ clearTimeout(timer);
11
+ timer = setTimeout(function () {
12
+ fn.apply(context, args);
13
+ }, delay);
14
+ };
15
+ }
16
+ };
17
+
18
+ Ucpengine.LivePreview = {
19
+ selectors: {
20
+ textarea: 'form textarea',
21
+ preview: '#live-preview'
22
+ },
23
+
24
+ initialize: function() {
25
+ $(document).on('keyup', this.selectors.textarea, Ucpengine.Utils.debounce(this.generatePreview.bind(this), 200));
26
+ },
27
+
28
+ generatePreview: function(event) {
29
+ var preview = $(this.selectors.preview);
30
+ var previewUrl = preview.attr('data-preview-url');
31
+
32
+ $.ajax({
33
+ type: 'POST',
34
+ url: previewUrl,
35
+ data: {
36
+ text: event.target.value
37
+ },
38
+
39
+ success: function(data) {
40
+ preview.html(data);
41
+ }
42
+ });
43
+ }
44
+ };
45
+
46
+ Ucpengine.LivePreview.initialize();
File without changes
@@ -0,0 +1,61 @@
1
+ .navbar-fixed{
2
+ height:50px !important;
3
+ }
4
+ nav {
5
+ height:50px !important;
6
+ background-color: #FFF!important;
7
+ .brand-logo{
8
+ padding:5px !important;
9
+ font-size:1rem !important;
10
+ img{
11
+ max-width: 200px !important;
12
+ }
13
+ }
14
+ }
15
+
16
+ .collection{border:none !important;}
17
+ .sidenav-item{
18
+ background-color:#ececec !important;
19
+ a{
20
+ color:#202c31;
21
+ font-size:1.2em;
22
+ font-weight: 300;
23
+ letter-spacing: 1px;
24
+ }
25
+ }
26
+ .row{
27
+ height:1200px;
28
+ .col{
29
+ padding:0 !important;
30
+ }
31
+ }
32
+ .ucp-sidenav{
33
+ height:100%;
34
+ background:#ececec ;
35
+ }
36
+
37
+ .ucp-title{
38
+ text-align: center;
39
+ font-size:1.2em;
40
+ font-weight: 300;
41
+ letter-spacing: 1px;
42
+ background: #202c31;
43
+ color:#FFF;
44
+ padding: 18px;
45
+ margin-top: 0;
46
+ }
47
+
48
+ .btn{
49
+ background-color:#4a6471 !important;
50
+ }
51
+
52
+ .dashboard-welcome{
53
+ text-align:center;
54
+ padding-top:250px;
55
+ p{
56
+ font-size: 1.8em;
57
+ font-weight: 300;
58
+ letter-spacing: 2px;
59
+ color:#28343a;
60
+ }
61
+ }
@@ -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,41 @@
1
+ module Ucpengine
2
+ class ApplicationController < ActionController::Base
3
+ before_action :authenticate_user
4
+
5
+ protected
6
+
7
+ def current_user
8
+ unless defined?(@current_user)
9
+ @current_user = instance_eval(&Ucpengine.configuration.current_user_lookup)
10
+ end
11
+ @current_user
12
+ end
13
+ helper_method :current_user
14
+
15
+ def authenticate_user
16
+ return if current_user
17
+
18
+ redirect_to instance_eval(&Ucpengine.configuration.sign_in_url)
19
+ end
20
+
21
+ def content_entries_path
22
+ entries_path(content_class: content_class.tableize)
23
+ end
24
+ helper_method :content_entries_path
25
+
26
+ def content_entry_path(entry)
27
+ entry_path(entry, content_class: content_class.tableize)
28
+ end
29
+ helper_method :content_entry_path
30
+
31
+ def new_content_entry_path
32
+ new_entry_path(content_class: content_class.tableize)
33
+ end
34
+ helper_method :new_content_entry_path
35
+
36
+ def edit_content_entry_path(entry)
37
+ edit_entry_path(entry, content_class: content_class.tableize)
38
+ end
39
+ helper_method :edit_content_entry_path
40
+ end
41
+ end
@@ -0,0 +1,8 @@
1
+ require_dependency "ucpengine/application_controller"
2
+
3
+ module Ucpengine
4
+ class DashboardController < ApplicationController
5
+ def index
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,62 @@
1
+ require_dependency "ucpengine/application_controller"
2
+
3
+ module Ucpengine
4
+ class EntriesController < ApplicationController
5
+ before_action :set_entry, only: [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ @entries = Entry.where(type: content_class)
9
+ end
10
+
11
+ def show
12
+ end
13
+
14
+ def new
15
+ @entry = Entry.new(type: content_class)
16
+ end
17
+
18
+ def edit
19
+ end
20
+
21
+ def create
22
+ @entry = Entry.new(entry_params)
23
+
24
+ if @entry.save
25
+ redirect_to content_entry_path(@entry), notice: 'Entry was successfully created.'
26
+ else
27
+ render :new
28
+ end
29
+ end
30
+
31
+ def update
32
+ if @entry.update(entry_params)
33
+ redirect_to content_entry_path(@entry), notice: 'Entry was successfully updated.'
34
+ else
35
+ render :edit
36
+ end
37
+ end
38
+
39
+ def destroy
40
+ @entry.destroy
41
+ redirect_to content_entries_path, notice: 'Entry was successfully destroyed.'
42
+ end
43
+
44
+ private
45
+
46
+ def set_entry
47
+ @entry = Entry.find(params[:id])
48
+ end
49
+
50
+ def entry_params
51
+ allowed_attrs = %i(id type termsofservice version slug published_at)
52
+ .concat(content_class.constantize.content_attributes.keys)
53
+
54
+ params.require(:entry).permit(*allowed_attrs)
55
+ end
56
+
57
+ def content_class
58
+ @content_class ||= params[:content_class].classify
59
+ end
60
+ helper_method :content_class
61
+ end
62
+ end
@@ -0,0 +1,9 @@
1
+ require_dependency "ucpengine/application_controller"
2
+
3
+ module Ucpengine
4
+ class PreviewsController < ApplicationController
5
+ def show
6
+ render layout: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module Ucpengine
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ucpengine
2
+ module EntriesHelper
3
+ end
4
+ end
@@ -0,0 +1,27 @@
1
+ module Ucpengine
2
+ module MarkdownHelper
3
+ class HTMLwithPygments < ::Redcarpet::Render::HTML
4
+ include ::Redcarpet::Render::SmartyPants
5
+
6
+ def block_code(code, language)
7
+ Pygments.highlight(code, lexer: language)
8
+ end
9
+ end
10
+
11
+ def markdown(text)
12
+ renderer = HTMLwithPygments.new(hard_wrap: true, filter_html: false)
13
+ options = {
14
+ filter_html: false,
15
+ autolink: true,
16
+ no_intra_emphasis: true,
17
+ fenced_code_blocks: true,
18
+ lax_html_blocks: true,
19
+ strikethrough: true,
20
+ superscript: true,
21
+ tables: true,
22
+ footnotes: true
23
+ }
24
+ ::Redcarpet::Markdown.new(renderer, options).render(text.to_s).html_safe
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,34 @@
1
+ module Ucpengine
2
+ module Concerns
3
+ module Searchable
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ has_many :search_data, class_name: 'Ucpengine::EntrySearchData'
8
+ #after_save :update_search_index
9
+ end
10
+
11
+ def searchable_attributes(*args)
12
+ @searchable_attributes = args if args.any?
13
+ @searchable_attributes ||= []
14
+ end
15
+
16
+ def search(query)
17
+ select('DISTINCT ON (entry_id) entry_id, wellspring_entries.*').
18
+ joins(:search_data).
19
+ where("search_data @@ plainto_tsquery('english', :q)", q: query).
20
+ order("entry_id, ts_rank(search_data, plainto_tsquery('%s')) desc" % send(:sanitize_sql, query))
21
+ end
22
+ end
23
+
24
+ def search_attributes
25
+ self.class.searchable_attributes.each_with_object({}) do |attr_name, search_data|
26
+ search_data[attr_name] = send(attr_name)
27
+ end
28
+ end
29
+
30
+ def update_search_index
31
+ Ucpengine::EntrySearchData.index_entry_data(id, search_attributes)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ module Ucpengine
2
+ class Entry < ActiveRecord::Base
3
+ scope :published, -> { where('published_at <= ?', Time.zone.now) }
4
+ include Ucpengine::Concerns::Searchable
5
+ def self.content_attr(attr_name, attr_type = :string)
6
+ content_attributes[attr_name] = attr_type
7
+
8
+ define_method(attr_name) do
9
+ self.payload ||= {}
10
+ self.payload[attr_name.to_s]
11
+ end
12
+
13
+ define_method("#{attr_name}=".to_sym) do |value|
14
+ self.payload ||= {}
15
+ self.payload[attr_name.to_s] = value
16
+ end
17
+ end
18
+
19
+ def self.content_attributes
20
+ @content_attributes ||= {}
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module Ucpengine
2
+ class EntrySearchData < ActiveRecord::Base
3
+ belongs_to :entry
4
+
5
+ validates :entry_id, presence: true
6
+ validates :attr_name, presence: true, uniqueness: { scope: :entry_id }
7
+
8
+ def self.index_entry_data(entry_id, search_attributes)
9
+ search_attributes.each do |attr_name, value|
10
+ find_or_create_by(entry_id: entry_id, attr_name: attr_name)
11
+
12
+ where(entry_id: entry_id, attr_name: attr_name).update_all([
13
+ "raw_data = :search_data, search_data = to_tsvector('english', :search_data)",
14
+ search_data: value
15
+ ])
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ucpengine</title>
5
+ <%= stylesheet_link_tag "ucpengine/application", media: "all" %>
6
+ <%= javascript_include_tag "ucpengine/application" %>
7
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.8/css/materialize.min.css">
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+ <div class="navbar-fixed">
12
+ <nav>
13
+ <div class="nav-wrapper">
14
+ <a href="#!" class="brand-logo"><img src="http://www.unitedcp.com/wp-content/uploads/logo.png"></a>
15
+ </div>
16
+ </nav>
17
+ </div>
18
+ <div class="row">
19
+
20
+ <div class="col s3 ucp-sidenav">
21
+
22
+ <p class="ucp-title">UCP cms Dashboard</p>
23
+
24
+ <ul class="collection">
25
+ <% Ucpengine.configuration.content_classes.each do |class_name| %>
26
+ <li class="collection-item sidenav-item">
27
+ <%= link_to 'Terms of Service', entries_path(content_class: class_name.tableize) %>
28
+ </li>
29
+ <% end %>
30
+ </ul>
31
+ </div>
32
+
33
+ <div class="col s9">
34
+
35
+ <%= yield %>
36
+ </div>
37
+ </div>
38
+ </body>
39
+ </html>
@@ -0,0 +1,3 @@
1
+ <div class="container dashboard-welcome">
2
+ <p>Welcome to the UCP cms dashboard. Easily create and manage multiple Terms of Service versions.</p>
3
+ </div>
@@ -0,0 +1,25 @@
1
+ <div class="row">
2
+ <div class="container">
3
+ <%= form_for(@entry, as: :entry, url: @entry.persisted? ? content_entry_path(@entry) : entries_path) do |f| %>
4
+ <%= f.hidden_field :type, value: @entry.type %>
5
+
6
+ <%= f.label :version %>
7
+ <%= f.text_field :version %>
8
+
9
+ <%= f.label :published_at %>
10
+ <%= f.text_field :published_at %>
11
+
12
+ <%= f.label :termsofservice %>
13
+ <%= f.text_field :termsofservice %>
14
+
15
+ <% @entry.class.content_attributes.each do |attr_name, attr_type| %>
16
+ <%= f.text_field attr_name, as: attr_type %>
17
+ <% end %>
18
+
19
+
20
+
21
+ <%= f.submit "Save" %>
22
+ <% end %>
23
+ <div id="live-preview" data-preview-url="<%= preview_path %>"></div>
24
+ </div>
25
+ </div>
@@ -0,0 +1,6 @@
1
+ <h1>Editing <%= content_class.titleize %></h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', content_entry_path(@entry) %> |
6
+ <%= link_to 'Back', content_entries_path %>
@@ -0,0 +1,15 @@
1
+ <%= content_class.tableize.titleize %>
2
+
3
+ <%= link_to "New #{content_class.titleize}", new_content_entry_path, class: 'btn btn-primary space-2' %>
4
+
5
+ <ul class="collection">
6
+ <% @entries.each do |entry| %>
7
+ <li class="collection-item">
8
+ <%= link_to entry.termsofservice, content_entry_path(entry) %>
9
+ <%= time_ago_in_words entry.created_at %> ago
10
+ <%= entry.version %>
11
+ <%= link_to 'Edit', edit_content_entry_path(entry) %>
12
+ <%= link_to 'Destroy', content_entry_path(entry), method: :delete, data: { confirm: 'Are you sure?' } %>
13
+ </li>
14
+ <% end %>
15
+ </ul>
@@ -0,0 +1,7 @@
1
+ New <%= content_class.titleize %>
2
+
3
+ <div class="row">
4
+ <%= render 'form' %>
5
+ </div>
6
+
7
+ <%= link_to 'Back', content_entries_path %>
@@ -0,0 +1,21 @@
1
+ <p>
2
+ <strong>Content class:</strong>
3
+ <%= @entry.type %>
4
+ </p>
5
+
6
+ <p>
7
+ <strong>Terms of Service:</strong>
8
+ <%= @entry.termsofservice %>
9
+ </p>
10
+
11
+
12
+ <% @entry.class.content_attributes.each do |attr_name, attr_type| %>
13
+ <p>
14
+ <strong><%= attr_name %>:</strong>
15
+ <%= @entry.send(attr_name.to_sym) %>
16
+ </p>
17
+ <% end %>
18
+
19
+
20
+ <%= link_to 'Edit', edit_content_entry_path(@entry) %> |
21
+ <%= link_to 'Back', content_entries_path %>
@@ -0,0 +1 @@
1
+ <%= markdown(params[:text]) %>
@@ -0,0 +1,31 @@
1
+ en:
2
+ simple_form:
3
+ "yes": 'Yes'
4
+ "no": 'No'
5
+ required:
6
+ text: 'required'
7
+ mark: '*'
8
+ # You can uncomment the line below if you need to overwrite the whole required html.
9
+ # When using html, text and mark won't be used.
10
+ # html: '<abbr title="required">*</abbr>'
11
+ error_notification:
12
+ default_message: "Please review the problems below:"
13
+ # Examples
14
+ # labels:
15
+ # defaults:
16
+ # password: 'Password'
17
+ # user:
18
+ # new:
19
+ # email: 'E-mail to sign in.'
20
+ # edit:
21
+ # email: 'E-mail.'
22
+ # hints:
23
+ # defaults:
24
+ # username: 'User name to sign in.'
25
+ # password: 'No special characters, please.'
26
+ # include_blanks:
27
+ # defaults:
28
+ # age: 'Rather not say'
29
+ # prompts:
30
+ # defaults:
31
+ # age: 'Select your age'
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Ucpengine::Engine.routes.draw do
2
+ post 'preview', to: 'preview#show', as: :preview
3
+
4
+ scope "/:content_class" do
5
+ resources :entries
6
+ end
7
+
8
+ root to: 'dashboard#index'
9
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUcpengineEntries < ActiveRecord::Migration
2
+ def change
3
+ create_table :ucpengine_entries do |t|
4
+ t.string :type, index: true
5
+ t.text :termsofservice
6
+ t.json :payload
7
+ t.integer :user_id, index: true
8
+
9
+ t.decimal :version
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ class CreateUcpengineEntrySearchData < ActiveRecord::Migration
2
+ def change
3
+ create_table :ucpengine_entry_search_data do |t|
4
+ t.integer :entry_id
5
+ t.string :attr_name
6
+ t.tsvector :search_data
7
+ t.text :raw_data
8
+
9
+ t.timestamps null: false
10
+ end
11
+
12
+ execute 'create index idx_search_data on ucpengine_entries_search_data using gin(search_data)'
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class AddSlugToUcpengineEntries < ActiveRecord::Migration
2
+ def change
3
+ add_column :ucpengine_entries, :slug, :string, index: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddPublishedAtToUcpengineEntries < ActiveRecord::Migration
2
+ def change
3
+ add_column :ucpengine_entries, :published_at, :datetime
4
+ end
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :ucpengine do
3
+ # # Task goes here
4
+ # end