unsakini 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -5
  3. data/app/controllers/api/boards_controller.rb +8 -2
  4. data/app/controllers/api/comments_controller.rb +1 -1
  5. data/app/controllers/api/posts_controller.rb +1 -1
  6. data/app/controllers/api/share_board_controller.rb +7 -7
  7. data/app/controllers/api/users_controller.rb +1 -1
  8. data/app/controllers/concerns/board_owner_controller_concern.rb +2 -2
  9. data/app/controllers/concerns/comment_owner_controller_concern.rb +2 -2
  10. data/app/controllers/concerns/logged_in_controller_concern.rb +1 -1
  11. data/app/controllers/concerns/post_owner_controller_concern.rb +2 -2
  12. data/app/controllers/web_base_controller.rb +4 -0
  13. data/app/models/user_board.rb +11 -0
  14. data/app/serializers/user_board_serializer.rb +2 -1
  15. data/app/views/web_base/index.html +16 -0
  16. data/config/routes.rb +3 -0
  17. data/db/migrate/20161124102633_add_is_shared_to_boards.rb +5 -0
  18. data/lib/tasks/unsakini_tasks.rake +28 -30
  19. data/lib/unsakini/engine.rb +7 -8
  20. data/lib/unsakini/version.rb +1 -1
  21. data/spec/{requests/render_app_index_spec.rb → controllers/web_base_controller_spec.rb} +7 -0
  22. data/spec/dummy/app/assets/config/manifest.js +2 -0
  23. data/spec/dummy/app/assets/javascripts/cable.js +13 -0
  24. data/spec/dummy/app/controllers/application_controller.rb +2 -1
  25. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  26. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  27. data/spec/dummy/config/application.rb +0 -7
  28. data/spec/dummy/config/environments/development.rb +7 -0
  29. data/spec/dummy/config/environments/production.rb +8 -0
  30. data/spec/dummy/config/initializers/assets.rb +11 -0
  31. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  32. data/spec/dummy/config/initializers/new_framework_defaults.rb +6 -0
  33. data/spec/dummy/config/initializers/session_store.rb +3 -0
  34. data/spec/dummy/config/routes.rb +1 -1
  35. data/spec/dummy/config/secrets.yml +2 -2
  36. data/spec/dummy/db/development.sqlite3 +0 -0
  37. data/spec/dummy/db/migrate/20161124184342_add_is_shared_to_boards.unsakini_engine.rb +6 -0
  38. data/spec/dummy/public/404.html +67 -0
  39. data/spec/dummy/public/422.html +67 -0
  40. data/spec/dummy/public/500.html +66 -0
  41. data/spec/dummy/public/app/index.html +0 -14
  42. data/spec/dummy/public/app/inline.map +1 -1
  43. data/spec/dummy/public/app/main.bundle.js +110 -64
  44. data/spec/dummy/public/app/main.map +1 -1
  45. data/spec/dummy/public/app/styles.map +1 -1
  46. data/spec/dummy/tmp/unsakini-ng2/LICENSE +21 -0
  47. data/spec/dummy/tmp/unsakini-ng2/README.md +1 -0
  48. data/{angular → spec/dummy/tmp/unsakini-ng2}/angular-cli.json +1 -1
  49. data/spec/dummy/tmp/unsakini-ng2/src/app/registration/registration.component.css +0 -0
  50. data/spec/models/user_board_spec.rb +2 -0
  51. data/spec/requests/api/boards/api_boards_crud_spec.rb +174 -0
  52. data/spec/requests/api/boards/api_boards_pagination_spec.rb +51 -0
  53. data/spec/requests/api/{api_boards_spec.rb → boards/api_private_board_spec.rb} +1 -98
  54. data/spec/requests/api/boards/api_shared_board_spec.rb +66 -0
  55. data/spec/support/scenario_helper.rb +66 -34
  56. data/spec/support/serialize_helper.rb +4 -0
  57. metadata +154 -127
  58. data/angular/README.md +0 -31
  59. data/config/initializers/unsakini.rb +0 -4
  60. data/spec/dummy/angular/README.md +0 -31
  61. data/spec/dummy/angular/angular-cli.json +0 -59
  62. data/spec/dummy/angular/karma.conf.js +0 -45
  63. data/spec/dummy/angular/package.json +0 -49
  64. data/spec/dummy/angular/protractor.conf.js +0 -32
  65. data/spec/dummy/angular/src/app/app.component.html +0 -4
  66. data/spec/dummy/angular/src/app/app.component.spec.ts +0 -47
  67. data/spec/dummy/angular/src/app/app.component.ts +0 -10
  68. data/spec/dummy/angular/src/app/app.module.ts +0 -29
  69. data/spec/dummy/angular/src/app/app.routes.module.ts +0 -29
  70. data/spec/dummy/angular/src/app/index.ts +0 -2
  71. data/spec/dummy/angular/src/app/registration/registration.component.html +0 -14
  72. data/spec/dummy/angular/src/app/registration/registration.component.spec.ts +0 -157
  73. data/spec/dummy/angular/src/app/registration/registration.component.ts +0 -42
  74. data/spec/dummy/angular/src/environments/environment.prod.ts +0 -3
  75. data/spec/dummy/angular/src/environments/environment.ts +0 -8
  76. data/spec/dummy/angular/src/favicon.ico +0 -0
  77. data/spec/dummy/angular/src/index.html +0 -14
  78. data/spec/dummy/angular/src/main.ts +0 -12
  79. data/spec/dummy/angular/src/polyfills.ts +0 -19
  80. data/spec/dummy/angular/src/styles.css +0 -1
  81. data/spec/dummy/angular/src/test.ts +0 -31
  82. data/spec/dummy/angular/src/tsconfig.json +0 -18
  83. data/spec/dummy/angular/src/typings.d.ts +0 -2
  84. data/spec/dummy/angular/tslint.json +0 -114
  85. data/spec/dummy/angular/typings.json +0 -4
  86. data/spec/dummy/config/crypto.yml +0 -7
  87. data/spec/dummy/config/initializers/cors.rb +0 -16
  88. data/spec/dummy/db/schema.rb +0 -56
  89. data/spec/dummy/db/test.sqlite3 +0 -0
  90. /data/spec/dummy/db/migrate/{20161123150822_create_boards.unsakini_engine.rb → 20161124184336_create_boards.unsakini_engine.rb} +0 -0
  91. /data/spec/dummy/db/migrate/{20161123150823_create_user_boards.unsakini_engine.rb → 20161124184337_create_user_boards.unsakini_engine.rb} +0 -0
  92. /data/spec/dummy/db/migrate/{20161123150824_create_posts.unsakini_engine.rb → 20161124184338_create_posts.unsakini_engine.rb} +0 -0
  93. /data/spec/dummy/db/migrate/{20161123150825_create_comments.unsakini_engine.rb → 20161124184339_create_comments.unsakini_engine.rb} +0 -0
  94. /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
  95. /data/spec/dummy/db/migrate/{20161123150827_create_users.unsakini_engine.rb → 20161124184341_create_users.unsakini_engine.rb} +0 -0
  96. /data/{angular/src/app/app.component.css → spec/dummy/public/apple-touch-icon-precomposed.png} +0 -0
  97. /data/{angular/src/app/registration/registration.component.css → spec/dummy/public/apple-touch-icon.png} +0 -0
  98. /data/spec/dummy/{angular/src/app/app.component.css → public/favicon.ico} +0 -0
  99. /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.e2e-spec.ts +0 -0
  100. /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/app.po.ts +0 -0
  101. /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.e2e-spec.ts +0 -0
  102. /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/signup.po.ts +0 -0
  103. /data/spec/dummy/{angular → tmp/unsakini-ng2}/e2e/tsconfig.json +0 -0
  104. /data/{angular → spec/dummy/tmp/unsakini-ng2}/karma.conf.js +0 -0
  105. /data/{angular → spec/dummy/tmp/unsakini-ng2}/package.json +0 -0
  106. /data/{angular → spec/dummy/tmp/unsakini-ng2}/protractor.conf.js +0 -0
  107. /data/spec/dummy/{angular/src/app/registration/registration.component.css → tmp/unsakini-ng2/src/app/app.component.css} +0 -0
  108. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.html +0 -0
  109. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.spec.ts +0 -0
  110. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.component.ts +0 -0
  111. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.module.ts +0 -0
  112. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/app.routes.module.ts +0 -0
  113. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/index.ts +0 -0
  114. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.html +0 -0
  115. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.spec.ts +0 -0
  116. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/app/registration/registration.component.ts +0 -0
  117. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.prod.ts +0 -0
  118. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/environments/environment.ts +0 -0
  119. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/favicon.ico +0 -0
  120. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/index.html +0 -0
  121. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/main.ts +0 -0
  122. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/polyfills.ts +0 -0
  123. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/styles.css +0 -0
  124. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/test.ts +0 -0
  125. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/tsconfig.json +0 -0
  126. /data/{angular → spec/dummy/tmp/unsakini-ng2}/src/typings.d.ts +0 -0
  127. /data/{angular → spec/dummy/tmp/unsakini-ng2}/tslint.json +0 -0
  128. /data/{angular → spec/dummy/tmp/unsakini-ng2}/typings.json +0 -0
  129. /data/spec/requests/api/{api_share_board_spec.rb → boards/api_sharing_board_spec.rb} +0 -0
  130. /data/spec/requests/api/{board/post/api_board_post_comments_spec.rb → comments/api_comments_spec.rb} +0 -0
  131. /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: e1f7610a7b1efe62c3b15aec2b07754e303a134e
4
- data.tar.gz: 109ce1ca7cc41e28c30552208ae6464d6f913dfb
3
+ metadata.gz: 9e311411b1d327c53b11377bb4a7785bb532cb34
4
+ data.tar.gz: 5f9b10bc0a7897d62e95c2ad5b7e63d26de10bf9
5
5
  SHA512:
6
- metadata.gz: 59b4a535023fb8336a688f365d4020a129157c0a0724707f3a08dfe850f07653b999d566fd5cb60386df036e5d871d2c7d88c2d4a08d71a528454f20dfb87b7e
7
- data.tar.gz: b1c52c6ccb7c51ac5b7fba768700c5444d715290196dc45fde2a47bae2aa92cf708885eb9bc90f4d95e413e83df8772e3912310a1d2855cf69570838d19d7c78
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
- render json: @user.user_boards
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
@@ -46,6 +46,6 @@ class Api::CommentsController < ApplicationController
46
46
  # `DELETE /api/boards/:board_id/posts/:post_id/comments/:id`
47
47
  def destroy
48
48
  @comment.destroy
49
- render status: :ok
49
+ render json: {}, status: :ok
50
50
  end
51
51
  end
@@ -52,7 +52,7 @@ class Api::PostsController < ApplicationController
52
52
  # `DELETE /api/boards/:board_id/posts/:id`
53
53
  def destroy
54
54
  @post.destroy
55
- render status: :ok
55
+ render json: {}, status: :ok
56
56
  end
57
57
 
58
58
  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 status: 422, json: ["Some of the data can't be saved."]
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
@@ -20,7 +20,7 @@ class Api::UsersController < ApplicationController
20
20
  if user
21
21
  render json: user
22
22
  else
23
- render status: :not_found
23
+ render json: {}, status: :not_found
24
24
  end
25
25
  end
26
26
 
@@ -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
@@ -14,7 +14,7 @@ module LoggedInControllerConcern
14
14
  private
15
15
  # Sets the `@user` variable in the controllers
16
16
  def set_user
17
- render status: :unauthorized if current_user.nil?
17
+ render json: {}, status: :unauthorized if current_user.nil?
18
18
  @user = current_user
19
19
  end
20
20
 
@@ -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
@@ -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
@@ -3,8 +3,9 @@
3
3
  #
4
4
 
5
5
  class UserBoardSerializer < ActiveModel::Serializer
6
+
6
7
  attributes :id, :is_admin, :encrypted_password, :created_at, :updated_at
7
- belongs_to :board
8
8
 
9
+ belongs_to :board
9
10
 
10
11
  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
@@ -0,0 +1,5 @@
1
+ class AddIsSharedToBoards < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :boards, :is_shared, :boolean, default: false
4
+ end
5
+ end
@@ -3,49 +3,47 @@ namespace :unsakini do
3
3
 
4
4
  desc "Runs `rails generate unsakini:config`"
5
5
  task :config do
6
- system('bundle exec rails g unsakini:config')
7
- end
8
-
9
- desc "Runs `rails generate unsakini:angular`"
10
- task :angular do
11
- system('bundle exec rails g unsakini:angular')
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
- desc "Initializes the angular app in ./angular directory."
15
- task :build do
13
+ Please run `bin/rails g unsakini:config` before you proceed.
16
14
 
17
- ng_dir = 'angular'
18
- lib_dir = "#{File.expand_path File.dirname(__FILE__)}"
19
- lib_dir.slice!("/lib/tasks")
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 "#{Rails.root}/#{ng_dir}" do
23
-
24
- cmd = ''
25
- cmd += 'npm i;'
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
- Please run `rails g unsakini:angular` before you proceed.
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, :angular, :build] do
41
+ task :install => [:config, :ng2] do
46
42
  begin
47
- system('bundle exec rake unsakini_engine:install:migrations')
48
- system('bundle exec rake db:migrate')
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 \
@@ -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
- # config.middleware.insert_before 0, Rack::Cors do
16
- # allow do
17
- # origins '*'
18
- # resource '*', :headers => :any, :methods => [:get, :post, :options]
19
- # end
20
- # end
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
 
@@ -1,3 +1,3 @@
1
1
  module Unsakini
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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
@@ -1,3 +1,5 @@
1
1
 
2
+ //= link_tree ../images
2
3
  //= link_directory ../javascripts .js
3
4
  //= link_directory ../stylesheets .css
5
+ //= link unsakini_manifest.js
@@ -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);
@@ -1,2 +1,3 @@
1
- class ApplicationController < ActionController::API
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery with: :exception
2
3
  end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -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 )
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Specify a serializer for the signed and encrypted cookie jars.
4
+ # Valid options are :json, :marshal, and :hybrid.
5
+ Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -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
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,3 @@
1
1
  Rails.application.routes.draw do
2
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
2
+ mount Unsakini::Engine => "/unsakini"
3
3
  end
@@ -11,10 +11,10 @@
11
11
  # if you're sharing your code publicly.
12
12
 
13
13
  development:
14
- secret_key_base: 1b46203fb68eed9b11f677f65351da99e30516e57b57f97eb13f9392b77164148efcbbe207038ad8b92ae9a59c3eb9a59ef4905bdc2eda7a7d36605d950fda75
14
+ secret_key_base: f6fb620af3cebd56ea3fee4feee28c4922b3291260f5069bb674128791a38b1685d47a4608fb581e60a6629f62519471583919b8f2caf5c4ecdb75195f09fb84
15
15
 
16
16
  test:
17
- secret_key_base: ddd3336ce2f4f519603191fe76b68317e92780f2bfed622e1752361448a161fbbc6feac40b3e471e8d231ef57cd0f9751ac77e4ed619ccd7ce899292af62088d
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
@@ -0,0 +1,6 @@
1
+ # This migration comes from unsakini_engine (originally 20161124102633)
2
+ class AddIsSharedToBoards < ActiveRecord::Migration[5.0]
3
+ def change
4
+ add_column :boards, :is_shared, :boolean, default: false
5
+ end
6
+ end