tomify 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +19 -0
  4. data/Rakefile +6 -0
  5. data/app/assets/images/tomify/gifs/basketball.gif +0 -0
  6. data/app/assets/images/tomify/gifs/laughing.gif +0 -0
  7. data/app/assets/images/tomify/gifs/sneer.gif +0 -0
  8. data/app/assets/images/tomify/gifs/wind.gif +0 -0
  9. data/app/assets/images/tomify/gifs/woods.gif +0 -0
  10. data/app/assets/javascripts/tomify/default/array.coffee +4 -0
  11. data/app/assets/javascripts/tomify/default/jquery.patch.coffee +9 -0
  12. data/app/assets/javascripts/tomify/default/object.coffee +4 -0
  13. data/app/assets/javascripts/tomify/default/string.coffee +40 -0
  14. data/app/assets/javascripts/tomify/dynamic/classes/component.coffee +7 -0
  15. data/app/assets/javascripts/tomify/dynamic/classes/field.coffee +24 -0
  16. data/app/assets/javascripts/tomify/dynamic/classes/form.coffee +72 -0
  17. data/app/assets/javascripts/tomify/dynamic/classes/model.coffee +41 -0
  18. data/app/assets/javascripts/tomify/dynamic/classes/namespace.coffee +24 -0
  19. data/app/assets/javascripts/tomify/dynamic/classes/observer.coffee +22 -0
  20. data/app/assets/javascripts/tomify/dynamic/classes/request.coffee +26 -0
  21. data/app/assets/javascripts/tomify/dynamic/classes/store.coffee +37 -0
  22. data/app/assets/javascripts/tomify/dynamic/global.coffee +16 -0
  23. data/app/assets/javascripts/tomify/dynamic/react/components/admin/pages.coffee.erb +30 -0
  24. data/app/assets/javascripts/tomify/dynamic/react/components/admin/settings.coffee +27 -0
  25. data/app/assets/javascripts/tomify/dynamic/react/components/admin/sidebars.coffee +16 -0
  26. data/app/assets/javascripts/tomify/dynamic/react/components/admin/uploads.coffee +13 -0
  27. data/app/assets/javascripts/tomify/dynamic/react/components/admin/users.coffee +18 -0
  28. data/app/assets/javascripts/tomify/dynamic/react/components/edit.coffee +51 -0
  29. data/app/assets/javascripts/tomify/dynamic/react/components/fields/checkbox.coffee +8 -0
  30. data/app/assets/javascripts/tomify/dynamic/react/components/fields/default.coffee +3 -0
  31. data/app/assets/javascripts/tomify/dynamic/react/components/fields/file.coffee +3 -0
  32. data/app/assets/javascripts/tomify/dynamic/react/components/fields/markdown.coffee +9 -0
  33. data/app/assets/javascripts/tomify/dynamic/react/components/fields/select.coffee +8 -0
  34. data/app/assets/javascripts/tomify/dynamic/react/components/fields/textarea.coffee +3 -0
  35. data/app/assets/javascripts/tomify/dynamic/react/components/index.coffee +87 -0
  36. data/app/assets/javascripts/tomify/dynamic/react/components/layout/admin_navbar.coffee +29 -0
  37. data/app/assets/javascripts/tomify/dynamic/react/components/layout/analytics.coffee +34 -0
  38. data/app/assets/javascripts/tomify/dynamic/react/components/layout/footer.coffee +11 -0
  39. data/app/assets/javascripts/tomify/dynamic/react/components/layout/header.coffee +28 -0
  40. data/app/assets/javascripts/tomify/dynamic/react/components/layout/messages.coffee +18 -0
  41. data/app/assets/javascripts/tomify/dynamic/react/components/layout/navbar.coffee +6 -0
  42. data/app/assets/javascripts/tomify/dynamic/react/components/layout/public_navbar.coffee +56 -0
  43. data/app/assets/javascripts/tomify/dynamic/react/components/new.coffee +48 -0
  44. data/app/assets/javascripts/tomify/dynamic/react/components/pagination.coffee +29 -0
  45. data/app/assets/javascripts/tomify/dynamic/react/components/public/passwords/new.coffee +38 -0
  46. data/app/assets/javascripts/tomify/dynamic/react/components/public/sessions/new.coffee +40 -0
  47. data/app/assets/javascripts/tomify/dynamic/react/components/public/sessions/show.coffee +35 -0
  48. data/app/assets/javascripts/tomify/dynamic/react/components/public/users/edit.coffee +42 -0
  49. data/app/assets/javascripts/tomify/dynamic/react/components/public/users/new.coffee +35 -0
  50. data/app/assets/javascripts/tomify/dynamic/react/mixins/follow.coffee +51 -0
  51. data/app/assets/javascripts/tomify/dynamic/react/mixins/will-initialize.coffee +7 -0
  52. data/app/assets/javascripts/tomify/dynamic/react/mount.coffee +9 -0
  53. data/app/assets/javascripts/tomify/turbolinks/compatibility.coffee +29 -0
  54. data/app/assets/javascripts/tomify/turbolinks/react.coffee +5 -0
  55. data/app/assets/javascripts/tomify-dynamic.js +8 -0
  56. data/app/assets/javascripts/tomify.js +1 -0
  57. data/app/assets/stylesheets/_tomify.scss +1 -0
  58. data/app/assets/stylesheets/tomify/_default.scss +26 -0
  59. data/app/assets/stylesheets/tomify/_footer.scss +1 -0
  60. data/app/assets/stylesheets/tomify/_navbar.scss +43 -0
  61. data/app/assets/stylesheets/tomify/_page.scss +31 -0
  62. data/app/assets/stylesheets/tomify/_pagination.scss +5 -0
  63. data/app/assets/stylesheets/tomify/_variables.scss +10 -0
  64. data/app/controllers/tomify/admin/controller.rb +7 -0
  65. data/app/controllers/tomify/admin/pages_controller.rb +2 -0
  66. data/app/controllers/tomify/admin/settings_controller.rb +2 -0
  67. data/app/controllers/tomify/admin/sidebars_controller.rb +2 -0
  68. data/app/controllers/tomify/admin/uploads_controller.rb +2 -0
  69. data/app/controllers/tomify/admin/users_controller.rb +2 -0
  70. data/app/controllers/tomify/api/admin/controller.rb +3 -0
  71. data/app/controllers/tomify/api/admin/pages_controller.rb +2 -0
  72. data/app/controllers/tomify/api/admin/settings_controller.rb +2 -0
  73. data/app/controllers/tomify/api/admin/sidebars_controller.rb +2 -0
  74. data/app/controllers/tomify/api/admin/uploads_controller.rb +2 -0
  75. data/app/controllers/tomify/api/admin/users_controller.rb +7 -0
  76. data/app/controllers/tomify/api/public/controller.rb +3 -0
  77. data/app/controllers/tomify/api/public/passwords_controller.rb +10 -0
  78. data/app/controllers/tomify/api/public/sessions_controller.rb +19 -0
  79. data/app/controllers/tomify/api/public/users_controller.rb +25 -0
  80. data/app/controllers/tomify/concerns/api/admin.rb +9 -0
  81. data/app/controllers/tomify/concerns/api/helpers.rb +57 -0
  82. data/app/controllers/tomify/concerns/api/json.rb +46 -0
  83. data/app/controllers/tomify/concerns/api/public.rb +9 -0
  84. data/app/controllers/tomify/concerns/default/auth_helper.rb +22 -0
  85. data/app/controllers/tomify/concerns/default/env_helper.rb +34 -0
  86. data/app/controllers/tomify/concerns/default/helper.rb +13 -0
  87. data/app/controllers/tomify/concerns/default/react_helper.rb +7 -0
  88. data/app/controllers/tomify/concerns/default.rb +17 -0
  89. data/app/controllers/tomify/public/controller.rb +2 -0
  90. data/app/controllers/tomify/public/pages_controller.rb +22 -0
  91. data/app/controllers/tomify/public/sessions_controller.rb +5 -0
  92. data/app/controllers/tomify/public/users_controller.rb +7 -0
  93. data/app/controllers/tomify_controller.rb +3 -0
  94. data/app/helpers/tomify/carrierwave_helper.rb +17 -0
  95. data/app/helpers/tomify/email_helper.rb +19 -0
  96. data/app/helpers/tomify/render_helper.rb +13 -0
  97. data/app/helpers/tomify/timezone_helper.rb +5 -0
  98. data/app/mailers/tomify/user_mailer.rb +13 -0
  99. data/app/mailers/tomify_mailer.rb +14 -0
  100. data/app/models/tomify/concerns/page.rb +74 -0
  101. data/app/models/tomify/concerns/sidebar.rb +18 -0
  102. data/app/models/tomify/concerns/token.rb +18 -0
  103. data/app/models/tomify/concerns/upload.rb +36 -0
  104. data/app/models/tomify/concerns/user.rb +52 -0
  105. data/app/models/tomify/page.rb +3 -0
  106. data/app/models/tomify/setting/boolean.rb +11 -0
  107. data/app/models/tomify/setting/json.rb +11 -0
  108. data/app/models/tomify/setting/text.rb +3 -0
  109. data/app/models/tomify/setting/uploader.rb +6 -0
  110. data/app/models/tomify/setting.rb +48 -0
  111. data/app/models/tomify/sidebar.rb +3 -0
  112. data/app/models/tomify/token.rb +3 -0
  113. data/app/models/tomify/upload.rb +3 -0
  114. data/app/models/tomify/user.rb +3 -0
  115. data/app/models/tomify_record.rb +33 -0
  116. data/app/uploaders/tomify/file_uploader.rb +5 -0
  117. data/app/uploaders/tomify/setting_uploader.rb +7 -0
  118. data/app/uploaders/tomify_uploader.rb +20 -0
  119. data/app/views/templates/contact.haml +24 -0
  120. data/app/views/templates/default.haml +4 -0
  121. data/app/views/tomify/defaults/_body.haml +8 -0
  122. data/app/views/tomify/defaults/_container.haml +3 -0
  123. data/app/views/tomify/defaults/_env.haml +2 -0
  124. data/app/views/tomify/defaults/_head.haml +14 -0
  125. data/app/views/tomify/defaults/_meta.haml +17 -0
  126. data/app/views/tomify/defaults/_sharing.haml +23 -0
  127. data/app/views/tomify/layouts/application.haml +4 -0
  128. data/app/views/tomify/layouts/mailer.haml +7 -0
  129. data/app/views/tomify/mailers/user_mailer/invite.haml +13 -0
  130. data/app/views/tomify/mailers/user_mailer/reset_password.haml +17 -0
  131. data/config/initializers/assets.rb +7 -0
  132. data/config/initializers/database.rb +3 -0
  133. data/config/initializers/flash_patch.rb +15 -0
  134. data/config/initializers/mailer.rb +4 -0
  135. data/config/initializers/renderers.rb +4 -0
  136. data/config/initializers/settings.rb +5 -0
  137. data/config/routes.rb +38 -0
  138. data/db/migrate/19900000000000_create_users.rb +13 -0
  139. data/db/migrate/19900000000001_create_tokens.rb +10 -0
  140. data/db/migrate/19900000000002_create_settings.rb +13 -0
  141. data/db/migrate/19900000000003_create_uploads.rb +13 -0
  142. data/db/migrate/19900000000004_create_pages.rb +22 -0
  143. data/db/migrate/19900000000005_create_sidebars.rb +12 -0
  144. data/db/seeds.rb +43 -0
  145. data/lib/generators/tomify/bundle/bundle_generator.rb +12 -0
  146. data/lib/generators/tomify/bundle/templates/default.js +2 -0
  147. data/lib/generators/tomify/bundle/templates/react.js +3 -0
  148. data/lib/previews/tomify/user_preview.rb +9 -0
  149. data/lib/previews/tomify_preview.rb +6 -0
  150. data/lib/tasks/package.rake +40 -0
  151. data/lib/tomify/constantly.rb +12 -0
  152. data/lib/tomify/engine.rb +11 -0
  153. data/lib/tomify/version.rb +3 -0
  154. data/lib/tomify.rb +40 -0
  155. data/vendor/tomify/development/react.js +20494 -0
  156. data/vendor/tomify/production/react.js +20352 -0
  157. metadata +219 -0
@@ -0,0 +1,13 @@
1
+ class CreateSettings < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :settings do |t|
4
+ t.boolean :public, default: true, null: false, index: true
5
+ t.string :type, null: false, index: true
6
+ t.string :name, null: false, index: true
7
+ t.string :value
8
+ t.json :json, default: {}, null: false
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUploads < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :uploads do |t|
4
+ t.string :uuid, null: false, index: true
5
+ t.string :name, null: false, index: true
6
+ t.string :file, null: false
7
+ t.string :size, null: false
8
+ t.string :content_type, null: false
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,22 @@
1
+ class CreatePages < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :pages do |t|
4
+ t.integer :parent_id, index: true
5
+ t.integer :sidebar_id
6
+ t.boolean :active, default: false, null: false, index: true
7
+ t.boolean :root, default: false, null: false, index: true
8
+ t.integer :rank, default: 100, null: false, index: true
9
+ t.string :path, null: false, index: true
10
+ t.string :name, null: false
11
+ t.string :template, null: false
12
+ t.string :title
13
+ t.string :description
14
+ t.string :cover_image
15
+ t.string :share_image
16
+ t.text :text
17
+
18
+ t.timestamps null: false
19
+ t.index [:active, :rank]
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,12 @@
1
+ class CreateSidebars < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :sidebars do |t|
4
+ t.boolean :active, default: false, null: false, index: true
5
+ t.string :name, null: false
6
+ t.string :heading
7
+ t.text :text
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
data/db/seeds.rb ADDED
@@ -0,0 +1,43 @@
1
+ def debug(record)
2
+ puts record.errors.full_messages unless record.valid?
3
+ end
4
+
5
+ if Tomify.models.user.count.zero?
6
+ puts "Creating Default Users"
7
+ debug Tomify.models.user.create(
8
+ admin: true,
9
+ email: "tom@tomify.me",
10
+ first_name: "Tom",
11
+ last_name: "Prats",
12
+ password: "password"
13
+ )
14
+ end
15
+
16
+ if Tomify.models.setting.count.zero?
17
+ puts "Creating Default Settings"
18
+ debug Tomify::Setting::Text.create(name: "name", value: "Tomify", public: true)
19
+ debug Tomify::Setting::Text.create(name: "timezone", value: "Eastern Time (US & Canada)")
20
+ debug Tomify::Setting::Boolean.create(name: "allow_signup", value: false, public: true)
21
+ debug Tomify::Setting::Json.create(name: "aws", value: {
22
+ access_key: "",
23
+ secret_key: "",
24
+ bucket: "",
25
+ })
26
+ debug Tomify::Setting::Json.create(name: "email", value: {
27
+ username: "",
28
+ password: "",
29
+ base_url: "http://localhost:3000"
30
+ })
31
+ end
32
+
33
+ if Tomify.models.page.count.zero?
34
+ puts "Creating Default Pages"
35
+ debug Tomify.models.page.create(
36
+ root: true,
37
+ active: true,
38
+ rank: 10,
39
+ path: "home",
40
+ name: "Home",
41
+ template: Tomify.models.page.templates.first
42
+ )
43
+ end
@@ -0,0 +1,12 @@
1
+ module Tomify
2
+ module Generators
3
+ class BundleGenerator < ::Rails::Generators::NamedBase
4
+ desc "Creates a default bundle js file"
5
+ source_root File.expand_path("../templates", __FILE__)
6
+
7
+ def create_default
8
+ copy_file "default.js", "config/bundles/#{file_name}.js"
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,2 @@
1
+ // npm-package
2
+ import Package from "npm-package";
@@ -0,0 +1,3 @@
1
+ // react react-dom
2
+ window.React = require("react");
3
+ window.ReactDOM = require("react-dom");
@@ -0,0 +1,9 @@
1
+ class UserPreview < Tomify.mailers.preview
2
+ def invite
3
+ Tomify::UserMailer.invite(user)
4
+ end
5
+
6
+ def reset_password
7
+ Tomify::UserMailer.reset_password(user)
8
+ end
9
+ end
@@ -0,0 +1,6 @@
1
+ class TomifyPreview < ActionMailer::Preview
2
+ private
3
+ def user
4
+ Tomify.models.user.find_by(email: "tom@tomify.me")
5
+ end
6
+ end
@@ -0,0 +1,40 @@
1
+ require "active_support/core_ext/object/blank"
2
+
3
+ namespace :tomify do
4
+ desc "Generate Package from Bundle"
5
+ task :package do
6
+ root = Gem::Specification.find_by_name("tomify").gem_dir
7
+
8
+ # Should be passed as arguments
9
+ package = "react.js"
10
+ package_bundle = "#{root}/lib/generators/tomify/bundle/templates/react.js"
11
+
12
+ package_path = package.split("/")[0...-1].join("/")
13
+ package_path = "#{pwd}/vendor/tomify" if package_path.blank?
14
+ package_name = package.split("/")[-1]
15
+ development = create_file "#{package_path}/development", package_name
16
+ production = create_file "#{package_path}/production", package_name
17
+
18
+ mkdir_p "tmp/tomify"
19
+ bundle = "#{pwd}/tmp/tomify/bundle.js"
20
+ cp package_bundle, bundle
21
+ cd "tmp/tomify" do
22
+ # Install
23
+ packages = File.read(bundle).match(/^\/\/ (.*)$/)[1]
24
+ sh "npm --loglevel=error install browserify #{packages}"
25
+
26
+ # Package
27
+ command = "node_modules/.bin/browserify"
28
+ sh "#{command} #{bundle} > #{development}"
29
+ sh "NODE_ENV=production #{command} #{bundle} > #{production}"
30
+ end
31
+ rm_rf "tmp/tomify"
32
+ end
33
+ end
34
+
35
+ def create_file(path, name)
36
+ file = "#{path}/#{name}"
37
+ mkdir_p path
38
+ touch file
39
+ file
40
+ end
@@ -0,0 +1,12 @@
1
+ module Tomify
2
+ class Constantly
3
+ def initialize(methods)
4
+ methods.each do |key, value|
5
+ define_singleton_method(key) { value.constantize }
6
+ define_singleton_method("#{key}=") do |new_value|
7
+ define_singleton_method(key) { new_value.constantize }
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ require "rake"
2
+
3
+ module Tomify
4
+ class Engine < ::Rails::Engine
5
+ rake_tasks do
6
+ Rake::Task["db:seed"].enhance do
7
+ load_seed
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module Tomify
2
+ VERSION = "0.0.0"
3
+ end
data/lib/tomify.rb ADDED
@@ -0,0 +1,40 @@
1
+ require "tomify/constantly"
2
+ require "tomify/engine"
3
+ require "tomify/version"
4
+
5
+ module Tomify
6
+ mattr_accessor :controllers
7
+ self.controllers = Constantly.new(
8
+ admin: "Tomify::Admin::Controller",
9
+ admin_api: "Tomify::Api::Admin::Controller",
10
+ base: "TomifyController",
11
+ public: "Tomify::Public::Controller",
12
+ public_api: "Tomify::Api::Public::Controller"
13
+ )
14
+
15
+ mattr_accessor :mailers
16
+ self.mailers = Constantly.new(
17
+ base: "TomifyMailer",
18
+ preview: "TomifyPreview",
19
+ user: "Tomify::UserMailer"
20
+ )
21
+
22
+ mattr_accessor :models
23
+ self.models = Constantly.new(
24
+ base: "TomifyRecord",
25
+ page: "Tomify::Page",
26
+ setting: "Tomify::Setting",
27
+ user: "Tomify::User"
28
+ )
29
+
30
+ mattr_accessor :uploaders
31
+ self.uploaders = Constantly.new(base: "TomifyUploader")
32
+
33
+ def self.root
34
+ Pathname.new Gem::Specification.find_by_name("tomify").gem_dir
35
+ end
36
+
37
+ def self.setting(name)
38
+ Tomify.models.setting.find_by(name: name).try(:value)
39
+ end
40
+ end