unsakini 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -5
- data/app/controllers/api/boards_controller.rb +8 -2
- data/app/controllers/api/comments_controller.rb +1 -1
- data/app/controllers/api/posts_controller.rb +1 -1
- data/app/controllers/api/share_board_controller.rb +7 -7
- data/app/controllers/api/users_controller.rb +1 -1
- data/app/controllers/concerns/board_owner_controller_concern.rb +2 -2
- data/app/controllers/concerns/comment_owner_controller_concern.rb +2 -2
- data/app/controllers/concerns/logged_in_controller_concern.rb +1 -1
- data/app/controllers/concerns/post_owner_controller_concern.rb +2 -2
- data/app/controllers/web_base_controller.rb +4 -0
- data/app/models/user_board.rb +11 -0
- data/app/serializers/user_board_serializer.rb +2 -1
- data/app/views/web_base/index.html +16 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20161124102633_add_is_shared_to_boards.rb +5 -0
- data/lib/tasks/unsakini_tasks.rake +28 -30
- data/lib/unsakini/engine.rb +7 -8
- data/lib/unsakini/version.rb +1 -1
- data/spec/{requests/render_app_index_spec.rb → controllers/web_base_controller_spec.rb} +7 -0
- data/spec/dummy/app/assets/config/manifest.js +2 -0
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +2 -1
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +0 -7
- data/spec/dummy/config/environments/development.rb +7 -0
- data/spec/dummy/config/environments/production.rb +8 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/new_framework_defaults.rb +6 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/config/secrets.yml +2 -2
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20161124184342_add_is_shared_to_boards.unsakini_engine.rb +6 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/app/index.html +0 -14
- data/spec/dummy/public/app/inline.map +1 -1
- data/spec/dummy/public/app/main.bundle.js +110 -64
- data/spec/dummy/public/app/main.map +1 -1
- data/spec/dummy/public/app/styles.map +1 -1
- data/spec/dummy/tmp/unsakini-ng2/LICENSE +21 -0
- data/spec/dummy/tmp/unsakini-ng2/README.md +1 -0
- data/{angular → spec/dummy/tmp/unsakini-ng2}/angular-cli.json +1 -1
- data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.css +0 -0
- data/spec/models/user_board_spec.rb +2 -0
- data/spec/requests/api/boards/api_boards_crud_spec.rb +174 -0
- data/spec/requests/api/boards/api_boards_pagination_spec.rb +51 -0
- data/spec/requests/api/{api_boards_spec.rb → boards/api_private_board_spec.rb} +1 -98
- data/spec/requests/api/boards/api_shared_board_spec.rb +66 -0
- data/spec/support/scenario_helper.rb +66 -34
- data/spec/support/serialize_helper.rb +4 -0
- metadata +154 -127
- data/angular/README.md +0 -31
- data/config/initializers/unsakini.rb +0 -4
- data/spec/dummy/angular/README.md +0 -31
- data/spec/dummy/angular/angular-cli.json +0 -59
- data/spec/dummy/angular/karma.conf.js +0 -45
- data/spec/dummy/angular/package.json +0 -49
- data/spec/dummy/angular/protractor.conf.js +0 -32
- data/spec/dummy/angular/src/app/app.component.html +0 -4
- data/spec/dummy/angular/src/app/app.component.spec.ts +0 -47
- data/spec/dummy/angular/src/app/app.component.ts +0 -10
- data/spec/dummy/angular/src/app/app.module.ts +0 -29
- data/spec/dummy/angular/src/app/app.routes.module.ts +0 -29
- data/spec/dummy/angular/src/app/index.ts +0 -2
- data/spec/dummy/angular/src/app/registration/registration.component.html +0 -14
- data/spec/dummy/angular/src/app/registration/registration.component.spec.ts +0 -157
- data/spec/dummy/angular/src/app/registration/registration.component.ts +0 -42
- data/spec/dummy/angular/src/environments/environment.prod.ts +0 -3
- data/spec/dummy/angular/src/environments/environment.ts +0 -8
- data/spec/dummy/angular/src/favicon.ico +0 -0
- data/spec/dummy/angular/src/index.html +0 -14
- data/spec/dummy/angular/src/main.ts +0 -12
- data/spec/dummy/angular/src/polyfills.ts +0 -19
- data/spec/dummy/angular/src/styles.css +0 -1
- data/spec/dummy/angular/src/test.ts +0 -31
- data/spec/dummy/angular/src/tsconfig.json +0 -18
- data/spec/dummy/angular/src/typings.d.ts +0 -2
- data/spec/dummy/angular/tslint.json +0 -114
- data/spec/dummy/angular/typings.json +0 -4
- data/spec/dummy/config/crypto.yml +0 -7
- data/spec/dummy/config/initializers/cors.rb +0 -16
- data/spec/dummy/db/schema.rb +0 -56
- data/spec/dummy/db/test.sqlite3 +0 -0
- /data/spec/dummy/db/migrate/{20161123150822_create_boards.unsakini_engine.rb → 20161124184336_create_boards.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150823_create_user_boards.unsakini_engine.rb → 20161124184337_create_user_boards.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150824_create_posts.unsakini_engine.rb → 20161124184338_create_posts.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150825_create_comments.unsakini_engine.rb → 20161124184339_create_comments.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150826_add_encrypted_password_to_user_board.unsakini_engine.rb → 20161124184340_add_encrypted_password_to_user_board.unsakini_engine.rb} +0 -0
- /data/spec/dummy/db/migrate/{20161123150827_create_users.unsakini_engine.rb → 20161124184341_create_users.unsakini_engine.rb} +0 -0
- /data/{angular/src/app/app.component.css → spec/dummy/public/apple-touch-icon-precomposed.png} +0 -0
- /data/{angular/src/app/registration/registration.component.css → spec/dummy/public/apple-touch-icon.png} +0 -0
- /data/spec/dummy/{angular/src/app/app.component.css → public/favicon.ico} +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.e2e-spec.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.po.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.e2e-spec.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.po.ts +0 -0
- /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/tsconfig.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/karma.conf.js +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/package.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/protractor.conf.js +0 -0
- /data/spec/dummy/{angular/src/app/registration/registration.component.css → tmp/unsakini-ng2/src/app/app.component.css} +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.spec.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.module.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.routes.module.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/index.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.spec.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.prod.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/favicon.ico +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/index.html +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/main.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/polyfills.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/styles.css +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/test.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/tsconfig.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/typings.d.ts +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/tslint.json +0 -0
- /data/{angular → spec/dummy/tmp/unsakini-ng2}/typings.json +0 -0
- /data/spec/requests/api/{api_share_board_spec.rb → boards/api_sharing_board_spec.rb} +0 -0
- /data/spec/requests/api/{board/post/api_board_post_comments_spec.rb → comments/api_comments_spec.rb} +0 -0
- /data/spec/requests/api/{board/api_board_posts_spec.rb → posts/api_posts_spec.rb} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e311411b1d327c53b11377bb4a7785bb532cb34
|
4
|
+
data.tar.gz: 5f9b10bc0a7897d62e95c2ad5b7e63d26de10bf9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d29b4053b9931a5ff0f1b982c953764ce0729fc53f02bcc37282196c25278389f63af1aa78b6e987ae2b3ce69b53f89ddea06e2320dab273340b47e5e3ac42b
|
7
|
+
data.tar.gz: 8e7146d7ddc0d454733f3836d13729585b8a47a8b805a70bf576abac0ee6943a408ec12a66f4f30836223521b861f073ac3dc3e18225537a5fddfa6a1570a064
|
data/Rakefile
CHANGED
@@ -12,6 +12,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
12
12
|
rdoc.options << '--line-numbers'
|
13
13
|
rdoc.rdoc_files.include('README.md')
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
rdoc.rdoc_files.include('app/**/*.rb')
|
15
16
|
end
|
16
17
|
|
17
18
|
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
@@ -19,13 +20,8 @@ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
19
20
|
load 'rails/tasks/engine.rake'
|
20
21
|
load 'rails/tasks/statistics.rake'
|
21
22
|
|
22
|
-
|
23
|
-
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
24
|
-
|
25
|
-
|
26
23
|
require 'rspec/core'
|
27
24
|
require 'rspec/core/rake_task'
|
28
|
-
|
29
25
|
require 'bundler/gem_tasks'
|
30
26
|
|
31
27
|
desc "Run all specs in spec directory (excluding plugin specs)"
|
@@ -14,7 +14,13 @@ class Api::BoardsController < ApplicationController
|
|
14
14
|
# `GET /api/boards`
|
15
15
|
#
|
16
16
|
def index
|
17
|
-
|
17
|
+
admin = true
|
18
|
+
shared = false
|
19
|
+
admin = params[:is_admin] == 'true' if params[:admin]
|
20
|
+
shared = params[:shared] == 'true' if params[:shared]
|
21
|
+
result = @user.user_boards.shared(shared)
|
22
|
+
result = result.admin if admin
|
23
|
+
paginate json: result, per_page: 10
|
18
24
|
end
|
19
25
|
|
20
26
|
# Creates board belonging to current user.
|
@@ -61,7 +67,7 @@ class Api::BoardsController < ApplicationController
|
|
61
67
|
# `DELETE /api/boards/:id`
|
62
68
|
def destroy
|
63
69
|
@board.destroy
|
64
|
-
render status: :ok
|
70
|
+
render json: {}, status: :ok
|
65
71
|
end
|
66
72
|
|
67
73
|
end
|
@@ -59,31 +59,31 @@ class Api::ShareBoardController < ApplicationController
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
if @user_board.share(params[:shared_user_ids], params[:encrypted_password])
|
62
|
-
render status: :ok
|
62
|
+
render json: {}, status: :ok
|
63
63
|
else
|
64
64
|
raise "An error occured"
|
65
65
|
end
|
66
66
|
end
|
67
67
|
rescue
|
68
68
|
# clean up the created {UserBoard}s
|
69
|
-
render
|
69
|
+
render json: ["Some of the data can't be saved."], status: 422
|
70
70
|
end
|
71
71
|
|
72
72
|
# Validates the contents of params against the database records.
|
73
73
|
def validate_params
|
74
74
|
|
75
75
|
if params[:encrypted_password].nil? or params[:shared_user_ids].nil? or params[:board].nil?
|
76
|
-
render status: 422
|
76
|
+
render json: {}, status: 422
|
77
77
|
return
|
78
78
|
end
|
79
79
|
|
80
80
|
result = has_board_access(params[:board][:id])
|
81
81
|
if result[:status] != :ok
|
82
|
-
render status: result[:status]
|
82
|
+
render json: {}, status: result[:status]
|
83
83
|
return
|
84
84
|
else
|
85
85
|
if !result[:user_board].is_admin
|
86
|
-
render status: :forbidden
|
86
|
+
render json: {}, status: :forbidden
|
87
87
|
return
|
88
88
|
end
|
89
89
|
@board = result[:board]
|
@@ -95,7 +95,7 @@ class Api::ShareBoardController < ApplicationController
|
|
95
95
|
params[:posts].each do |post|
|
96
96
|
s = has_post_access(params[:board][:id], post[:id])[:status]
|
97
97
|
if s != :ok
|
98
|
-
render status: s
|
98
|
+
render json: {}, status: s
|
99
99
|
return
|
100
100
|
end
|
101
101
|
|
@@ -103,7 +103,7 @@ class Api::ShareBoardController < ApplicationController
|
|
103
103
|
post[:comments].each do |comment|
|
104
104
|
s = has_comment_access(post[:id], comment[:id])[:status]
|
105
105
|
if s != :ok
|
106
|
-
render status: s
|
106
|
+
render json: {}, status: s
|
107
107
|
return
|
108
108
|
end
|
109
109
|
end
|
@@ -8,7 +8,7 @@ module BoardOwnerControllerConcern
|
|
8
8
|
result = has_board_access(board_id)
|
9
9
|
@board = result[:board]
|
10
10
|
@user_board = result[:user_board]
|
11
|
-
render status: result[:status] if result[:status] != :ok
|
11
|
+
render json: {}, status: result[:status] if result[:status] != :ok
|
12
12
|
end
|
13
13
|
|
14
14
|
# Validate if user has access to board
|
@@ -32,7 +32,7 @@ module BoardOwnerControllerConcern
|
|
32
32
|
|
33
33
|
#Ensures user is owner of the board. Must be run after {#ensure_board} method.
|
34
34
|
def ensure_board_owner
|
35
|
-
render status: :forbidden if !@user_board.is_admin
|
35
|
+
render json: {}, status: :forbidden if !@user_board.is_admin
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -9,7 +9,7 @@ module CommentOwnerControllerConcern
|
|
9
9
|
result = has_comment_access post_id, comment_id
|
10
10
|
@comment = result[:comment]
|
11
11
|
status = result[:status]
|
12
|
-
render status: status if status != :ok
|
12
|
+
render json: {}, status: status if status != :ok
|
13
13
|
end
|
14
14
|
|
15
15
|
# Validate if user has access to comment in the post
|
@@ -27,7 +27,7 @@ module CommentOwnerControllerConcern
|
|
27
27
|
|
28
28
|
# Ensures user is the owner of the comment. Must be run after {#ensure_comment} method.
|
29
29
|
def ensure_comment_owner
|
30
|
-
render status: :forbidden if @comment.user_id != @user.id
|
30
|
+
render json: {}, status: :forbidden if @comment.user_id != @user.id
|
31
31
|
end
|
32
32
|
|
33
33
|
end
|
@@ -9,7 +9,7 @@ module PostOwnerControllerConcern
|
|
9
9
|
result = has_post_access(board_id, post_id)
|
10
10
|
status = result[:status]
|
11
11
|
@post = result[:post]
|
12
|
-
render status: status if status != :ok
|
12
|
+
render json: {}, status: status if status != :ok
|
13
13
|
end
|
14
14
|
|
15
15
|
# Validate if user has access to the post in the board
|
@@ -30,7 +30,7 @@ module PostOwnerControllerConcern
|
|
30
30
|
|
31
31
|
# Ensures user is owner of the post. Must be run after {#ensure_post}`.
|
32
32
|
def ensure_post_owner
|
33
|
-
render status: :forbidden if @post.user_id != @user.id
|
33
|
+
render json: {}, status: :forbidden if @post.user_id != @user.id
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|
@@ -4,6 +4,10 @@ class WebBaseController < ActionController::Base
|
|
4
4
|
include ActionController::ImplicitRender
|
5
5
|
include ActionView::Layouts
|
6
6
|
|
7
|
+
# Renders welcome page
|
8
|
+
def index
|
9
|
+
end
|
10
|
+
|
7
11
|
# Renders the angular index view when request url is /app/* to enable html5 pushState capability of angularjs
|
8
12
|
def app
|
9
13
|
render file: "#{Rails.root}/public/app/index.html", layout: false
|
data/app/models/user_board.rb
CHANGED
@@ -12,6 +12,8 @@ class UserBoard < ApplicationRecord
|
|
12
12
|
belongs_to :user
|
13
13
|
belongs_to :board
|
14
14
|
|
15
|
+
scope :admin, -> { where(is_admin: true) }
|
16
|
+
|
15
17
|
def name=(str)
|
16
18
|
@name = str
|
17
19
|
end
|
@@ -24,6 +26,14 @@ class UserBoard < ApplicationRecord
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
29
|
+
# Returns user_boards where {Board} is `is_shared`
|
30
|
+
#
|
31
|
+
# @param is_shared [Boolean] wether to return shared or not shared boards
|
32
|
+
def self.shared(is_shared)
|
33
|
+
joins("LEFT JOIN boards ON user_boards.board_id = boards.id")
|
34
|
+
.where("boards.is_shared = ?", is_shared)
|
35
|
+
end
|
36
|
+
|
27
37
|
def share(user_ids, new_key)
|
28
38
|
ActiveRecord::Base.transaction do
|
29
39
|
user_ids.each do |usr_id|
|
@@ -35,6 +45,7 @@ class UserBoard < ApplicationRecord
|
|
35
45
|
})
|
36
46
|
.save!
|
37
47
|
end
|
48
|
+
self.board.is_shared = true
|
38
49
|
self.encrypted_password = new_key
|
39
50
|
self.save!
|
40
51
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="UTF-8">
|
5
|
+
<title>Welcome to Unsakini</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<h1>Welcome to Unsakini</h1>
|
9
|
+
<ul>
|
10
|
+
<li>
|
11
|
+
<a href="/app/login">Login</a>
|
12
|
+
<a href="/app/signup">Sign Up</a>
|
13
|
+
</li>
|
14
|
+
</ul>
|
15
|
+
</body>
|
16
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
root to: 'web_base#index'
|
2
4
|
|
3
5
|
post 'user_token' => 'user_token#create'
|
4
6
|
|
@@ -17,6 +19,7 @@ Rails.application.routes.draw do
|
|
17
19
|
post '/api/share/board/', to: 'share_board#index', as: 'share_board'
|
18
20
|
get '/api/users/search', to: 'users#search', as: 'user_search'
|
19
21
|
|
22
|
+
|
20
23
|
end
|
21
24
|
|
22
25
|
end
|
@@ -3,49 +3,47 @@ namespace :unsakini do
|
|
3
3
|
|
4
4
|
desc "Runs `rails generate unsakini:config`"
|
5
5
|
task :config do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
6
|
+
begin
|
7
|
+
Dir.chdir Rails.root do
|
8
|
+
system('bin/rails g unsakini:config')
|
9
|
+
end
|
10
|
+
rescue Exception => e
|
11
|
+
puts "
|
13
12
|
|
14
|
-
|
15
|
-
task :build do
|
13
|
+
Please run `bin/rails g unsakini:config` before you proceed.
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
"
|
16
|
+
end
|
17
|
+
end
|
20
18
|
|
19
|
+
desc "Installs the Angular 2 web client to public/app"
|
20
|
+
task :ng2 do
|
21
|
+
repo_name = "https://github.com/unsakini/unsakini-ng2"
|
22
|
+
tmp_dir = "#{Rails.root}/tmp/unsakini-ng2"
|
23
|
+
app_dir = "#{Rails.root}/public/app/"
|
21
24
|
begin
|
22
|
-
Dir.chdir
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
cmd += "#{Rails.root}/#{ng_dir}/node_modules/.bin/ng build"
|
27
|
-
cmd += " --prod" if Rails.env.production?
|
28
|
-
puts "Running #{cmd}"
|
29
|
-
system(cmd)
|
30
|
-
|
31
|
-
puts "Done installing angular assets."
|
25
|
+
Dir.chdir Rails.root do
|
26
|
+
system("rm -rf #{tmp_dir} #{app_dir}")
|
27
|
+
system("git clone #{repo_name} #{tmp_dir}")
|
28
|
+
system("mv #{tmp_dir}/dist #{app_dir}")
|
32
29
|
end
|
33
30
|
rescue Exception => e
|
34
|
-
puts
|
35
|
-
"
|
31
|
+
puts e.to_s
|
32
|
+
raise "
|
36
33
|
|
37
|
-
|
34
|
+
Please clone #{repo_name} and extract dist folder to your projects public/app folder
|
38
35
|
|
39
|
-
|
36
|
+
"
|
40
37
|
end
|
41
|
-
|
42
38
|
end
|
43
39
|
|
44
40
|
desc "One stop command to install unsakini."
|
45
|
-
task :install => [:config, :
|
41
|
+
task :install => [:config, :ng2] do
|
46
42
|
begin
|
47
|
-
|
48
|
-
|
43
|
+
Dir.chdir "#{Rails.root}" do
|
44
|
+
system("#{Rails.root}/bin/rake unsakini_engine:install:migrations")
|
45
|
+
system("#{Rails.root}/bin/rake db:migrate")
|
46
|
+
end
|
49
47
|
rescue Exception => e
|
50
48
|
puts e.to_s
|
51
49
|
puts \
|
data/lib/unsakini/engine.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
module Unsakini
|
4
2
|
class Engine < ::Rails::Engine
|
5
3
|
|
6
4
|
config.generators.api_only = true
|
5
|
+
config.unsakini_crypto_key = 'secret'
|
7
6
|
|
8
7
|
config.generators do |g|
|
9
8
|
g.test_framework :rspec, :fixture => false
|
@@ -12,12 +11,12 @@ module Unsakini
|
|
12
11
|
g.helper false
|
13
12
|
end
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
14
|
+
config.middleware.insert_before 0, "Rack::Cors" do
|
15
|
+
allow do
|
16
|
+
origins '*'
|
17
|
+
resource '*', :headers => :any, :methods => [:get, :post, :options]
|
18
|
+
end
|
19
|
+
end
|
21
20
|
|
22
21
|
end
|
23
22
|
|
data/lib/unsakini/version.rb
CHANGED
@@ -2,6 +2,12 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
RSpec.describe "WebBaseController", type: :request do
|
4
4
|
|
5
|
+
it "renders the welcome page" do
|
6
|
+
get "/"
|
7
|
+
expect(response).to have_http_status :ok
|
8
|
+
expect(response.body).to include('Welcome')
|
9
|
+
end
|
10
|
+
|
5
11
|
describe 'catch html5 pushState routes' do
|
6
12
|
|
7
13
|
def self.visit_app_urls(urls)
|
@@ -16,4 +22,5 @@ RSpec.describe "WebBaseController", type: :request do
|
|
16
22
|
visit_app_urls(['/app', 'app/', 'app/*anything'])
|
17
23
|
|
18
24
|
end
|
25
|
+
|
19
26
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// Action Cable provides the framework to deal with WebSockets in Rails.
|
2
|
+
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
3
|
+
//
|
4
|
+
//= require action_cable
|
5
|
+
//= require_self
|
6
|
+
//= require_tree ./channels
|
7
|
+
|
8
|
+
(function() {
|
9
|
+
this.App || (this.App = {});
|
10
|
+
|
11
|
+
App.cable = ActionCable.createConsumer();
|
12
|
+
|
13
|
+
}).call(this);
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
|
7
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
|
8
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<%= yield %>
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -10,13 +10,6 @@ module Dummy
|
|
10
10
|
# Settings in config/environments/* take precedence over those specified here.
|
11
11
|
# Application configuration should go into files in config/initializers
|
12
12
|
# -- all .rb files in that directory are automatically loaded.
|
13
|
-
|
14
|
-
# Only loads a smaller set of middleware suitable for API only apps.
|
15
|
-
# Middleware like session, flash, cookies can be added back manually.
|
16
|
-
# Skip views, helpers and assets when generating a new resource.
|
17
|
-
config.api_only = true
|
18
|
-
|
19
|
-
config.crypto = config_for(:crypto)
|
20
13
|
end
|
21
14
|
end
|
22
15
|
|
@@ -37,6 +37,13 @@ Rails.application.configure do
|
|
37
37
|
# Raise an error on page load if there are pending migrations.
|
38
38
|
config.active_record.migration_error = :page_load
|
39
39
|
|
40
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
41
|
+
# This option may cause significant delays in view rendering with a large
|
42
|
+
# number of complex assets.
|
43
|
+
config.assets.debug = true
|
44
|
+
|
45
|
+
# Suppress logger output for asset requests.
|
46
|
+
config.assets.quiet = true
|
40
47
|
|
41
48
|
# Raises error for missing translations
|
42
49
|
# config.action_view.raise_on_missing_translations = true
|
@@ -18,6 +18,14 @@ Rails.application.configure do
|
|
18
18
|
# Apache or NGINX already handles this.
|
19
19
|
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
20
20
|
|
21
|
+
# Compress JavaScripts and CSS.
|
22
|
+
config.assets.js_compressor = :uglifier
|
23
|
+
# config.assets.css_compressor = :sass
|
24
|
+
|
25
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
26
|
+
config.assets.compile = false
|
27
|
+
|
28
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
21
29
|
|
22
30
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
23
31
|
# config.action_controller.asset_host = 'http://assets.example.com'
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Version of your assets, change this if you want to expire all your assets.
|
4
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
@@ -4,6 +4,12 @@
|
|
4
4
|
#
|
5
5
|
# Read the Rails 5.0 release notes for more info on each option.
|
6
6
|
|
7
|
+
# Enable per-form CSRF tokens. Previous versions had false.
|
8
|
+
Rails.application.config.action_controller.per_form_csrf_tokens = true
|
9
|
+
|
10
|
+
# Enable origin-checking CSRF mitigation. Previous versions had false.
|
11
|
+
Rails.application.config.action_controller.forgery_protection_origin_check = true
|
12
|
+
|
7
13
|
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
|
8
14
|
# Previous versions had false.
|
9
15
|
ActiveSupport.to_time_preserves_timezone = true
|
data/spec/dummy/config/routes.rb
CHANGED
@@ -11,10 +11,10 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: f6fb620af3cebd56ea3fee4feee28c4922b3291260f5069bb674128791a38b1685d47a4608fb581e60a6629f62519471583919b8f2caf5c4ecdb75195f09fb84
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: b581fd9329cc8030701718e6caeb15960c58aa1017c1d97e45ffb6a7a027c7d7230b646c7ea121258ab08044ecb2f95fb756720d4566235393785be6968311be
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
Binary file
|