tomify 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57007dacbc53ef0792f799a4dd59ddc0f1fbd1aa
4
- data.tar.gz: c599f317a3bd1b022c2b6d3e1a5b108e5abb14a1
3
+ metadata.gz: 8ad48b3ce738012cd5586f14612a7c57517bde4d
4
+ data.tar.gz: 1fc96ad471a7221bfdebc6940b09dad8f628d5c1
5
5
  SHA512:
6
- metadata.gz: 219e26d3ce04cf98995c401ac4264f90932d316080ea2a4cec2427bbfb793302478087037f0c6731129e3cd2cb117ebf0eeb0003156d55803336ec3d7a258c25
7
- data.tar.gz: 931fcab4e391dcf69120fa1cbc71d2e460687388cc6be7f13e930f923f9ed6a4b1a29d24f8263b23437394db93081fd7f802dc786d869a95f7855f3108a82e30
6
+ metadata.gz: 71950755f898ab68dc1eb8254c872ebf9ca23241b50dfce9e236bac9985802142dc0db297cb0e70e752613f73e1356a2917527a379c9ff0387cb731268c6fdbe
7
+ data.tar.gz: cc9a1edaefeaf2fb3091de2269d2de8d146e6a84ef212898e2663af1a834316db39c0e8caeeeb0b79bd9bf17bf003b9fa6ed6b884bc69b23320388379a904735
@@ -1,12 +1,16 @@
1
1
  Store.create "Messages", []
2
+ Store.create "Page", {}
2
3
  Store.create "Pages", []
3
4
  Store.create "Params", {}
5
+ Store.create "Plugins", []
4
6
  Store.create "Settings", []
5
7
  Store.create "User", {}
8
+
6
9
  env = Store.create "Env", {}
7
10
  env.on "change", ->
8
11
  current = Store.find("Env").get()
9
12
  Store.find("Messages").set current.messages
13
+ Store.find("Page").set current.page
10
14
  Store.find("Pages").set current.pages
11
15
  Store.find("Settings").set current.settings
12
16
  Store.find("User").set current.user ? {}
@@ -30,3 +34,4 @@ $ ->
30
34
  page = Store.find("Pages").get().find (page) -> page.template == template
31
35
  page ?= { path: path ? template }
32
36
  if page.root then "/" else "/#{page.path}"
37
+ @addPlugin = (plugin) -> Store.find("Plugins").push plugin
@@ -24,6 +24,7 @@ form.add "parent_id", "select", model: "Admin.Page", allowBlank: true
24
24
  form.add "sidebar_id", "select", model: "Admin.Sidebar", allowBlank: true
25
25
  form.add "active", "checkbox"
26
26
  form.add "root", "checkbox", label: "If checked, this page will be available at <a href='/' target='_blank'>#{location.origin}</a>"
27
+ form.add "feedback", "checkbox"
27
28
  form.add "rank", "number"
28
29
  form.add "name", "text"
29
30
  form.add "template", "select", options: <%= Tomify::Page.templates %>
@@ -0,0 +1,10 @@
1
+ Component.create "Layout.Plugins",
2
+ followStores: ["plugins"]
3
+ render: ->
4
+ <div>
5
+ {for plugin, i in @state.plugins
6
+ Plugin = Component.find plugin
7
+
8
+ <Plugin key={i} />
9
+ }
10
+ </div>
@@ -0,0 +1,10 @@
1
+ Component.create "Public.FeedbackButton",
2
+ followStores: ["page"]
3
+ render: ->
4
+ return <div /> unless @state.page.feedback
5
+
6
+ <a href="#{path 'feedback'}?page=#{encodeURIComponent(location.href)}" className="feedback-button" title="Feedback">
7
+ <i className="fa fa-meh-o fa-2x" />
8
+ </a>
9
+
10
+ @addPlugin "Public.FeedbackButton"
@@ -13,6 +13,7 @@ Component.create "Public.Feedback",
13
13
  @form = form.setComponent @
14
14
  @follow @model.on "create", @modelCreate
15
15
  @model.new()
16
+ @form.changes.merge page: Store.find("Params").get("page")
16
17
  modelCreate: (response) ->
17
18
  message type: response.type, text: response.message
18
19
  @form.changes.set {} if response.type == "success"
@@ -0,0 +1,16 @@
1
+ .feedback-button {
2
+ width: 50px;
3
+ height: 50px;
4
+ position: fixed;
5
+ bottom: 20px;
6
+ right: 20px;
7
+ padding: 11px 0;
8
+ color: $white;
9
+ background-color: $brand;
10
+ border-radius: 50%;
11
+ text-align: center;
12
+ &:active, &:focus, &:hover {
13
+ color: $white;
14
+ background-color: $brand-primary;
15
+ }
16
+ }
@@ -3,11 +3,10 @@ class Tomify::Api::Admin::PagesController < Tomify.controllers.admin_api
3
3
  def permitted_attributes
4
4
  [
5
5
  :parent_id, :sidebar_id,
6
- :active, :root, :rank,
7
- :path, :name, :template,
8
- :title, :description,
9
- :cover_image, :share_image,
10
- :text
6
+ :active, :root, :feedback,
7
+ :rank, :path, :name,
8
+ :template, :title, :description,
9
+ :cover_image, :share_image, :text
11
10
  ]
12
11
  end
13
12
 
@@ -6,7 +6,7 @@ class Tomify::Api::Public::FeedbackController < Tomify.controllers.public_api
6
6
 
7
7
  private
8
8
  def permitted_attributes
9
- [:name, :email, :subject, :message]
9
+ [:name, :email, :subject, :message, :page]
10
10
  end
11
11
 
12
12
  def record_params
@@ -3,6 +3,7 @@ module Tomify::Concerns::Default::EnvHelper
3
3
  {
4
4
  messages: flash.collect { |key, value| { type: key, text: value }},
5
5
  navbar: navbar,
6
+ page: page.for_env,
6
7
  pages: Tomify.models.page.for_env,
7
8
  settings: Tomify.models.setting.for_env,
8
9
  user: current_user
@@ -8,6 +8,6 @@ module Tomify::Concerns::Default::Helper
8
8
  end
9
9
 
10
10
  def page
11
- @page || root_page
11
+ @page || Tomify.models.page.default
12
12
  end
13
13
  end
@@ -1,4 +1,10 @@
1
1
  class Tomify::Public::PagesController < Tomify.controllers.public
2
+ rescue_from "ActionController::RoutingError" do |e|
3
+ raise unless request.path[1..-1].in? ["feedback"]
4
+
5
+ render component: "Public.#{request.path[1..-1].capitalize}"
6
+ end
7
+
2
8
  def show
3
9
  @page = Tomify.models.page.find_by(path: params[:path]) || not_found
4
10
 
@@ -26,7 +26,13 @@ module Tomify::Concerns::Page
26
26
 
27
27
  class_methods do
28
28
  def root
29
- find_by(root: true) || new(root: true, name: "Home", path: "", template: "default")
29
+ find_by(root: true) || default
30
+ end
31
+
32
+ def default
33
+ feedback = Tomify.setting :feedback
34
+ feedback = feedback.nil? ? true : feedback
35
+ new(name: "Home", path: "", template: "default", feedback: feedback)
30
36
  end
31
37
 
32
38
  def templates
@@ -39,7 +45,14 @@ module Tomify::Concerns::Page
39
45
  end
40
46
 
41
47
  def for_env
42
- all.as_json(only: [:active, :name, :path, :root, :template, :parent_id])
48
+ all.as_json(env_serializable_options)
49
+ end
50
+
51
+ def env_serializable_options
52
+ { only: [
53
+ :active, :feedback, :name, :path,
54
+ :root, :template, :parent_id
55
+ ]}
43
56
  end
44
57
 
45
58
  def for_navbar
@@ -50,6 +63,10 @@ module Tomify::Concerns::Page
50
63
  end
51
64
  end
52
65
 
66
+ def for_env
67
+ as_json(self.class.env_serializable_options)
68
+ end
69
+
53
70
  private
54
71
  def parent_valid?
55
72
  errors.add(:parent_id) if parent && parent.id == id
@@ -6,3 +6,4 @@
6
6
  = tomify_render_for :footer, :layout
7
7
  = tomify_render_for :env, :layout
8
8
  = tomify_render_for :analytics, :layout
9
+ = tomify_render_for :plugins, :layout
@@ -1,4 +1,4 @@
1
- - sidebar = @page.sidebar if @page&.sidebar&.active
1
+ - sidebar = page.sidebar if page.sidebar&.active
2
2
  .container-fluid{class: "with#{"out" unless sidebar }-sidebar"}
3
3
  .row
4
4
  - if sidebar
@@ -6,6 +6,7 @@ class CreateFeedback < ActiveRecord::Migration[5.0]
6
6
  t.string :email, null: false
7
7
  t.string :subject, null: false
8
8
  t.string :message, null: false
9
+ t.string :page
9
10
  t.boolean :resolved, default: false, null: false, index: true
10
11
 
11
12
  t.timestamps
@@ -0,0 +1,5 @@
1
+ class AddFeedbackButtonToPages < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :pages, :feedback, :boolean, default: true, null: false
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module Tomify
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tomify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Prats
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-30 00:00:00.000000000 Z
11
+ date: 2017-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -286,9 +286,11 @@ files:
286
286
  - app/assets/javascripts/tomify/dynamic/react/components/layout/header.coffee
287
287
  - app/assets/javascripts/tomify/dynamic/react/components/layout/messages.coffee
288
288
  - app/assets/javascripts/tomify/dynamic/react/components/layout/navbar.coffee
289
+ - app/assets/javascripts/tomify/dynamic/react/components/layout/plugins.coffee
289
290
  - app/assets/javascripts/tomify/dynamic/react/components/layout/public_navbar.coffee
290
291
  - app/assets/javascripts/tomify/dynamic/react/components/new.coffee
291
292
  - app/assets/javascripts/tomify/dynamic/react/components/pagination.coffee
293
+ - app/assets/javascripts/tomify/dynamic/react/components/public/feedback-button.coffee
292
294
  - app/assets/javascripts/tomify/dynamic/react/components/public/feedback.coffee
293
295
  - app/assets/javascripts/tomify/dynamic/react/components/public/passwords/new.coffee
294
296
  - app/assets/javascripts/tomify/dynamic/react/components/public/profile.coffee
@@ -311,6 +313,7 @@ files:
311
313
  - app/assets/stylesheets/tomify/_navbar.scss
312
314
  - app/assets/stylesheets/tomify/_page.scss
313
315
  - app/assets/stylesheets/tomify/_pagination.scss
316
+ - app/assets/stylesheets/tomify/_plugins.scss
314
317
  - app/assets/stylesheets/tomify/_variables.scss
315
318
  - app/controllers/tomify/admin/controller.rb
316
319
  - app/controllers/tomify/admin/feedback_controller.rb
@@ -383,7 +386,6 @@ files:
383
386
  - app/uploaders/tomify_uploader.rb
384
387
  - app/views/templates/contact.haml
385
388
  - app/views/templates/default.haml
386
- - app/views/templates/feedback.haml
387
389
  - app/views/templates/sidebar.haml
388
390
  - app/views/tomify/defaults/_body.haml
389
391
  - app/views/tomify/defaults/_container.haml
@@ -421,6 +423,7 @@ files:
421
423
  - db/migrate/19900000000010_add_template_to_sidebars.rb
422
424
  - db/migrate/19900000000011_create_activities.rb
423
425
  - db/migrate/19900000000012_create_feedback.rb
426
+ - db/migrate/19900000000013_add_feedback_button_to_pages.rb
424
427
  - db/seeds.rb
425
428
  - lib/generators/tomify/bundle/bundle_generator.rb
426
429
  - lib/generators/tomify/bundle/templates/default.js
@@ -1 +0,0 @@
1
- = react_component "Public.Feedback"