tomify 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af725db32ac310b47ea7eefedfaf879b7b927040
4
- data.tar.gz: 80da5c622cdb34254d793df17e2919afcef6c98a
3
+ metadata.gz: f9da0a49b63fcfccfb5a385fe3c09ce92ce8f426
4
+ data.tar.gz: fc523774e05c2622f0f442421d190fb859f3a1f4
5
5
  SHA512:
6
- metadata.gz: 34a9285af9d4e3f98bc13e7173c7c0bf34ef3e932c0321bfa8bf651ad74dd06610ae64c8329675a8b0e72ff08a5cb4b6e2d6ac163f5fdb2e636b4bccd6dc37b4
7
- data.tar.gz: edd76bd3edf8f8545c2895a1066187822f42e302a58176cf4374b6e88857d36a6e1e5d4f1ff87147a68802d7243d587767196f955eb21f8ac15bd725555d3771
6
+ metadata.gz: 2e96cb8c60cdf77201dca2a2977d394b5c64b27891791241d3a2d2b21cd85827a6530087749b6015c30a241a80affd9be4d5bf3ce6260e663594d6c0e1ef8c33
7
+ data.tar.gz: 290e8c20b5bac654f3d935b02406f41b31d78aed6def226aafd3573b7f076493f47fc3650c61f1b5dd8493c2f0a3c25a42e4f378d7de7fc0c6646dccc1929626
@@ -4,10 +4,13 @@ model.columns = [
4
4
  { name: "public", value: (r) -> if r.public then "Yes" else "No" },
5
5
  { name: "type", value: (r) -> r.type.split("::").last },
6
6
  { name: "value", value: (r) ->
7
- type = r.type.split("::").last
8
- return "#{r.value}" if type == "Boolean"
9
- return "JSON" if type == "Json"
10
- r.value
7
+ return unless r.value?
8
+ switch type = r.type.split("::").last
9
+ when "Boolean" then "#{r.value}"
10
+ when "Uploader"
11
+ <a href={r.value.url} target="_blank">View</a>
12
+ when "Json" then "JSON"
13
+ else r.value
11
14
  },
12
15
  { name: "updated_at", value: (r) -> r.updated_at.date() },
13
16
  { name: "actions", edit: true, destroy: true }
@@ -22,6 +25,7 @@ newForm.add "public", "checkbox"
22
25
  newForm.add "name", "text"
23
26
  newForm.add "value", "checkbox", if: (record, changes) -> changes.type.split("::").last == "Boolean"
24
27
  newForm.add "value", "text", if: (record, changes) -> changes.type.split("::").last == "Text"
28
+ newForm.add "value", "file", if: (record, changes) -> changes.type.split("::").last == "Uploader"
25
29
  newForm.add "json", "json", if: (record, changes) -> changes.type.split("::").last == "Json"
26
30
 
27
31
  editForm = new Form "horizontal"
@@ -29,7 +33,7 @@ editForm.add "public", "checkbox"
29
33
  editForm.add "name", "text"
30
34
  editForm.add "value", "checkbox", if: (record) -> record.type.split("::").last == "Boolean"
31
35
  editForm.add "value", "text", if: (record) -> record.type.split("::").last == "Text"
36
+ editForm.add "value", "file", if: (record) -> record.type.split("::").last == "Uploader"
32
37
  editForm.add "json", "json", if: (record) -> record.type.split("::").last == "Json"
33
- # editForm.add "value", "json", if: (record) -> record.type.split("::").last == "Uploader"
34
38
 
35
39
  Component.create "Admin.Settings.Index.Container", render: -> <Index.Container name="Admin.Setting" newForm={newForm} editForm={editForm} />
@@ -2,27 +2,31 @@ Component.create "Layout.Header",
2
2
  render: ->
3
3
  image = setting "header_image"
4
4
  text = setting "header_text"
5
- return <div /> unless image && text
5
+ return <div /> unless image || text
6
6
 
7
- <div className="navbar navbar-default center header">
8
- <div className="container-fluid">
9
- <div className="row">
10
- <div className="col-lg-8 col-lg-offset-2">
7
+ image = image && <div className="header-image">
8
+ <a href="/">
9
+ <img src={image.url} alt="Logo" />
10
+ </a>
11
+ </div>
12
+
13
+ text = text && <div className="header-text">
14
+ <h3>{text}</h3>
15
+ </div>
16
+
17
+ <div className="container-fluid header">
18
+ <div className="row">
19
+ <div className="col-md-8 col-md-offset-2">
20
+ {if image && text
11
21
  <div className="row">
12
- <div className="col-sm-3">
13
- <div className="navbar-header">
14
- <a href="/" class="navbar-brand">
15
- <img src={image.url} alt="Logo" />
16
- </a>
17
- </div>
18
- </div>
19
- <div className="col-sm-9">
20
- <div className="navbar-text">
21
- <h3>{text}</h3>
22
- </div>
23
- </div>
22
+ <div className="col-sm-3">{image}</div>
23
+ <div className="col-sm-9">{text}</div>
24
+ </div>
25
+ else
26
+ <div className="header-center">
27
+ {if image then image else text}
24
28
  </div>
25
- </div>
29
+ }
26
30
  </div>
27
31
  </div>
28
32
  </div>
@@ -0,0 +1,34 @@
1
+ .header {
2
+ &.container-fluid {
3
+ margin-top: 10px;
4
+ margin-bottom: 10px;
5
+ }
6
+ .header-image {
7
+ display: inline-block;
8
+ height: 100%;
9
+ img { height: $header; }
10
+ }
11
+ .header-text {
12
+ line-height: $header;
13
+ text-align: right;
14
+ * {
15
+ margin: 0;
16
+ line-height: $header;
17
+ }
18
+ }
19
+ .header-center {
20
+ text-align: center;
21
+ .header-text { text-align: center; }
22
+ }
23
+ }
24
+
25
+ @media screen and (max-width: $screen-sm) {
26
+ .header {
27
+ text-align: center;
28
+ .header-image img {
29
+ height: auto;
30
+ max-width: 100%;
31
+ }
32
+ .header-text { text-align: center; }
33
+ }
34
+ }
@@ -10,7 +10,7 @@
10
10
  .navbar.center {
11
11
  text-align: center;
12
12
 
13
- .navbar-brand img { height: 100%; }
13
+ .navbar-brand { height: 100%; }
14
14
  }
15
15
 
16
16
  .navbar, .alert {
@@ -7,4 +7,6 @@ $brand: $green !default;
7
7
  $brand-primary: $blue !default;
8
8
  $brand-success: $green !default;
9
9
 
10
+ $header: 50px !default;
11
+
10
12
  @import "bootstrap/variables";
@@ -1,6 +1,7 @@
1
1
  class Tomify::Api::Public::PasswordsController < Tomify.controllers.public_api
2
2
  def create
3
3
  if user = Tomify.models.user.find_by(email: params[:password][:email])
4
+ user.activities.create(action: action_name, controller: controller_name)
4
5
  Tomify.mailers.user.reset_password(user).deliver_now
5
6
  render json: { type: :success, message: "Email Sent" }
6
7
  else
@@ -4,6 +4,7 @@ class Tomify::Api::Public::SessionsController < Tomify.controllers.public_api
4
4
  user = Tomify.models.user.find_by(email: email)
5
5
  if user && user.password_digest && user.authenticate(params[:session][:password])
6
6
  session[:current_user_id] = user.id
7
+ current_user.activities.create(action: action_name, controller: controller_name)
7
8
  flash[:success] = "Welcome #{current_user.name}!"
8
9
  render json: { type: :success }
9
10
  else
@@ -1,6 +1,7 @@
1
1
  class Tomify::Api::Public::SubscriptionsController < Tomify.controllers.public_api
2
2
  def destroy
3
3
  subscription = Tomify.models.subscription.find_or_create_by(email: params[:subscription][:email])
4
+ subscription.activities.create(action: action_name, controller: controller_name)
4
5
  if subscription.update(active: false)
5
6
  render json: { type: :success, message: "You have been unsubscribed from #{setting(:name)}" }
6
7
  else
@@ -5,6 +5,7 @@ class Tomify::Api::Public::UsersController < Tomify.controllers.public_api
5
5
 
6
6
  def create
7
7
  session[:current_user_id] = Tomify.models.user.create!(record_params).id
8
+ current_user.activities.create(action: action_name, controller: controller_name)
8
9
  render json: { type: :success }, success: "Welcome #{current_user.name}!"
9
10
  rescue ActiveRecord::RecordInvalid => e
10
11
  render json: { type: :warning, message: e.record.errors.full_messages.join(", ") }
@@ -12,6 +13,7 @@ class Tomify::Api::Public::UsersController < Tomify.controllers.public_api
12
13
 
13
14
  def update
14
15
  current_user.update!(record_params)
16
+ current_user.activities.create(action: action_name, controller: controller_name)
15
17
  render json: { type: :success, message: "Profile Updated" }
16
18
  rescue ActiveRecord::RecordInvalid => e
17
19
  render json: { type: :warning, message: e.record.errors.full_messages.join(", ") }
@@ -19,6 +21,7 @@ class Tomify::Api::Public::UsersController < Tomify.controllers.public_api
19
21
 
20
22
  def destroy
21
23
  flash[:danger] = "Goodbye #{current_user.name}"
24
+ current_user.activities.create(action: action_name, controller: controller_name)
22
25
  find_record
23
26
  destroy_record
24
27
  render json: { type: :success }
@@ -34,6 +34,6 @@ module Tomify::Concerns::Default::EnvHelper
34
34
  end
35
35
 
36
36
  def public_settings
37
- Tomify.models.setting.public.as_json(only: [:name, :value])
37
+ Tomify.models.setting.where(public: true).as_json(only: [:name, :value])
38
38
  end
39
39
  end
@@ -0,0 +1,3 @@
1
+ class Tomify::Activity < Tomify.models.base
2
+ include Tomify::Concerns::Activity
3
+ end
@@ -0,0 +1,13 @@
1
+ module Tomify::Concerns::Activity
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ belongs_to :trackable, polymorphic: true
6
+
7
+ default_scope { order(created_at: :desc) }
8
+ end
9
+
10
+ def trackable_kind
11
+ trackable_type.underscore.titleize
12
+ end
13
+ end
@@ -2,6 +2,8 @@ module Tomify::Concerns::Subscription
2
2
  extend ActiveSupport::Concern
3
3
 
4
4
  included do
5
+ has_many :activities, class_name: Tomify.models.activity.to_s, as: :trackable
6
+
5
7
  scope :active, -> { where(active: true) }
6
8
  scope :inactive, -> { where(active: false) }
7
9
  end
@@ -3,6 +3,7 @@ module Tomify::Concerns::User
3
3
 
4
4
  included do
5
5
  has_secure_password validations: false
6
+ has_many :activities, class_name: Tomify.models.activity.to_s, as: :trackable
6
7
  has_many :tokens, class_name: Tomify.models.token.to_s, dependent: :destroy
7
8
 
8
9
  before_validation :format_email
@@ -1,6 +1,3 @@
1
- class Tomify::UploaderSetting < Tomify::Setting
2
- mount_uploader :value, Tomify::SettingUploader
3
-
4
- validates_presence_of :json
5
- validate :metadata
1
+ class Tomify::Setting::Uploader < Tomify::Setting
2
+ mount_uploader :value, Tomify.uploaders.setting
6
3
  end
@@ -9,10 +9,6 @@ class Tomify::Setting < Tomify.models.base
9
9
  after_commit :update_config
10
10
  before_destroy { |record| !record.name.in? self.class.required_settings }
11
11
 
12
- def self.public
13
- where(public: true)
14
- end
15
-
16
12
  def self.required_settings
17
13
  ["allow_signup", "aws", "name", "email", "timezone"]
18
14
  end
@@ -1,7 +1,3 @@
1
1
  class Tomify::SettingUploader < Tomify.uploaders.base
2
- # in uploader
3
- # if image
4
- # width ||= 1000000000
5
- # height ||= -1
6
- # resize_to_fill width, height
2
+ process resize_to_fit: [1000000000, 100]
7
3
  end
@@ -0,0 +1,14 @@
1
+ class CreateActivities < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :activities do |t|
4
+ t.integer :trackable_id, null: false
5
+ t.string :trackable_type, null: false
6
+ t.string :action, null: false
7
+ t.string :controller, null: false
8
+
9
+ t.timestamps null: false
10
+ t.index [:trackable_id, :trackable_type]
11
+ t.index [:action, :controller]
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Tomify
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
data/lib/tomify.rb CHANGED
@@ -20,6 +20,7 @@ module Tomify
20
20
 
21
21
  mattr_accessor :models
22
22
  self.models = Constantly.new(
23
+ activity: "Tomify::Activity",
23
24
  base: "TomifyRecord",
24
25
  page: "Tomify::Page",
25
26
  setting: "Tomify::Setting",
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.0.8
4
+ version: 0.0.9
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-05-06 00:00:00.000000000 Z
11
+ date: 2017-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -304,6 +304,7 @@ files:
304
304
  - app/assets/stylesheets/_tomify.scss
305
305
  - app/assets/stylesheets/tomify/_default.scss
306
306
  - app/assets/stylesheets/tomify/_footer.scss
307
+ - app/assets/stylesheets/tomify/_header.scss
307
308
  - app/assets/stylesheets/tomify/_navbar.scss
308
309
  - app/assets/stylesheets/tomify/_page.scss
309
310
  - app/assets/stylesheets/tomify/_pagination.scss
@@ -346,6 +347,8 @@ files:
346
347
  - app/helpers/tomify/timezone_helper.rb
347
348
  - app/mailers/tomify/user_mailer.rb
348
349
  - app/mailers/tomify_mailer.rb
350
+ - app/models/tomify/activity.rb
351
+ - app/models/tomify/concerns/activity.rb
349
352
  - app/models/tomify/concerns/page.rb
350
353
  - app/models/tomify/concerns/sidebar.rb
351
354
  - app/models/tomify/concerns/subscription.rb
@@ -401,6 +404,7 @@ files:
401
404
  - db/migrate/19900000000008_add_name_to_tokens.rb
402
405
  - db/migrate/19900000000009_add_invited_to_users.rb
403
406
  - db/migrate/19900000000010_add_template_to_sidebars.rb
407
+ - db/migrate/19900000000011_create_activities.rb
404
408
  - db/seeds.rb
405
409
  - lib/generators/tomify/bundle/bundle_generator.rb
406
410
  - lib/generators/tomify/bundle/templates/default.js