jobshop 0.0.4.0p1 → 0.0.4.0p13

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: 73f32c72b0d85a46741051ac4eed44ec3afcc450
4
- data.tar.gz: f03e99a3069119e232c82b6e4553180e941d8955
3
+ metadata.gz: db8928c85fe8d5da471dcd3d6019453fee0fe672
4
+ data.tar.gz: 763e51b7b0abfca5a5ee5853ffa87c859fa892cf
5
5
  SHA512:
6
- metadata.gz: 64d8a1cee77f6d4ab1f477fdc210b0d48ace03ef943b267562dc0f13033044be3e44277230aa80c0c4e03fdae86e321a8c29fc9135924a8b771ac6a680832604
7
- data.tar.gz: d29e592ad90d5c80c4170fa44b0fe8597902065cea2266cabd579660ee2a29bd7043e4d80fa7c8e47f9cdf2d3885a1c1b0c8956a5eb8be64cc8a8773b882ad88
6
+ metadata.gz: f9cf806314eb0f51a5fca8f33e74e0895f78525146b0bb97814905b11f857b6692c74011d3e78da61bd2fd2d123db8af4a2afb27cb18f272407beccde4584d19
7
+ data.tar.gz: 25c0275b6f0ea2b874b90d4368d1923fae6d87526c9211791e2c382a11642a58e4de29a59ec6bca1793479f43c32f1430eba27e36e0af7ca20078de70a2d9010
@@ -12,4 +12,5 @@
12
12
  //
13
13
  //= require jquery
14
14
  //= require jquery_ujs
15
+ //= require materialize
15
16
  //= require_tree .
@@ -53,4 +53,4 @@ html {
53
53
  }
54
54
  }
55
55
 
56
- @import "pages/index";
56
+ @import "generics";
@@ -0,0 +1,25 @@
1
+ html {
2
+ body {
3
+ > header,
4
+ > main,
5
+ > footer {
6
+ display: flex;
7
+ flex-direction: column;
8
+ justify-content: center;
9
+ align-items: center;
10
+
11
+ > section {
12
+ @extend .card;
13
+ @extend .bubble;
14
+
15
+ max-width: 80%;
16
+ min-width: 38%;
17
+
18
+ @media #{$small-and-down} {
19
+ max-width: 100%;
20
+ width: 100%;
21
+ }
22
+ }
23
+ }
24
+ }
25
+ }
@@ -0,0 +1,3 @@
1
+ // Place all the styles related to the site/configuration controller here.
2
+ // They will automatically be included in application.css.
3
+ // You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,32 @@
1
+ require_dependency "jobshop/application_controller"
2
+
3
+ module Jobshop
4
+ class Sites::RegistrationsController < ApplicationController
5
+ before_action :authenticate_user!, unless: :configure_by_token?, only: :new
6
+
7
+ def new
8
+ @site = Jobshop::Site.find(params[:site_id])
9
+ authenticate_user! if @site.owner
10
+ @registration = Jobshop::Registration.new(params)
11
+ end
12
+
13
+ protected
14
+
15
+ def configure_by_token?
16
+ @configure_by_token ||= params[:configuration_token].present? &&
17
+ configuration_token_valid?
18
+ end
19
+
20
+ def configuration_token_valid?
21
+ @configuration_token_valid ||= begin
22
+ encrypted_configuration_token = Devise.token_generator.digest(
23
+ Jobshop::Site, :configuration_token, params[:configuration_token])
24
+
25
+ configurable = Jobshop::Site.find_by(
26
+ configuration_token: encrypted_configuration_token)
27
+
28
+ configurable && configurable.configuration_token_period_valid?
29
+ end
30
+ end
31
+ end
32
+ end
@@ -2,26 +2,5 @@ require_dependency "jobshop/application_controller"
2
2
 
3
3
  module Jobshop
4
4
  class SitesController < ApplicationController
5
- before_action :authenticate_user!, unless: :configure_by_token?, only: :edit
6
-
7
- def edit
8
-
9
- end
10
-
11
- protected
12
-
13
- def configure_by_token?
14
- params[:configuration_token].present? && configuration_token_valid?
15
- end
16
-
17
- def configuration_token_valid?
18
- encrypted_configuration_token = Devise.token_generator.digest(
19
- Jobshop::Site, :configuration_token, params[:configuration_token])
20
-
21
- configurable = Jobshop::Site.find_by(
22
- configuration_token: encrypted_configuration_token)
23
-
24
- configurable && configurable.configuration_token_period_valid?
25
- end
26
5
  end
27
6
  end
@@ -1,5 +1,8 @@
1
1
  module Jobshop
2
- class Site < ActiveRecord::Base
2
+ class Site < ApplicationRecord
3
+ belongs_to :owner, class_name: "Jobshop::User"
4
+ has_many :users, class_name: "Jobshop::User"
5
+
3
6
  def generate_configuration_token
4
7
  raw, encrypted = Devise.token_generator.generate(self.class, :configuration_token)
5
8
 
@@ -1,7 +1,9 @@
1
1
  module Jobshop
2
- class User < ActiveRecord::Base
2
+ class User < ApplicationRecord
3
3
  # Include default devise modules. Others available are:
4
4
  # :confirmable, :lockable, :timeoutable and :omniauthable
5
5
  devise :database_authenticatable, :recoverable, :rememberable, :validatable
6
+
7
+ belongs_to :site
6
8
  end
7
9
  end
@@ -0,0 +1,15 @@
1
+ require "jobshop/support/memo_attr"
2
+
3
+ module Jobshop
4
+ class ApplicationResource
5
+ include ActiveModel::Model
6
+ include MemoAttr
7
+
8
+ attr_reader :errors, :params
9
+
10
+ def initialize(params = ActionController::Parameters.new)
11
+ @errors = ActiveModel::Errors.new(self)
12
+ @params = params
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,26 @@
1
+ module Jobshop
2
+ class Registration < Jobshop::ApplicationResource
3
+ memo_attr(:user) { site.users.build(user_params) }
4
+ memo_attr(:site) { Jobshop::Site.find(params[:site_id]) }
5
+
6
+ def save
7
+ return false unless valid?
8
+
9
+ result = ActiveRecord::Base.transaction do
10
+ user.save!
11
+ site.update!(owner: user)
12
+ end
13
+
14
+ result != false
15
+ end
16
+
17
+ private
18
+ def site_params
19
+ params.fetch(:site, ActionController::Parameters.new).permit(:name)
20
+ end
21
+
22
+ def user_params
23
+ params.fetch(:user, ActionController::Parameters.new).permit(:email, :password, :password_confirmation)
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ %header
2
+ %object.logo{ type: "image/svg+xml", data: image_path("jobshop/logo.svg") }
3
+
4
+ %main
5
+ %section
6
+ = form_for @registration, url: site_registration_path(@registration.site) do |f|
7
+ .card-content
8
+ %h1.center Getting Started
9
+
10
+ %br
11
+ = f.fields_for(@registration.site) do |site_f|
12
+ %ul.input-field
13
+ %li= site_f.label(:name, "Organization") + site_f.text_field(:name)
14
+
15
+ = f.fields_for(@registration.user) do |user_f|
16
+ %ul.input-field
17
+ %li= user_f.label(:email) + user_f.email_field(:email)
18
+
19
+ %ul.input-field
20
+ %li= user_f.label(:password) + user_f.password_field(:password)
21
+
22
+ %ul.input-field
23
+ %li= user_f.label(:password_confirmation) + user_f.password_field(:password_confirmation)
24
+
25
+ %ul.right
26
+ %li= f.button "Next &#187;".html_safe, class: "btn waves-effect waves-light"
27
+
data/config/routes.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  Jobshop::Engine.routes.draw do
2
- get 'sites/edit'
3
-
4
2
  devise_for :users, class_name: "Jobshop::User", module: :devise
5
3
 
6
- resources :sites, only: [ :edit, :update ]
4
+ resources :sites, only: [ :edit ] do
5
+ resource :registration, only: [ :new, :create ],
6
+ controller: "sites/registrations"
7
+ end
7
8
 
8
9
  get "/" => "pages#show", page: "index"
9
10
  get "/about" => redirect("https://jobshop.io"), as: :about
@@ -0,0 +1,5 @@
1
+ class AddSiteIdToUsers < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :jobshop_users, :site_id, :uuid
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ class AddForeignKeyForSite < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_foreign_key :jobshop_users, :jobshop_sites, column: "site_id",
4
+ on_delete: :cascade
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ class AddOwnerIdToSites < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :jobshop_sites, :owner_id, :uuid
4
+ add_foreign_key :jobshop_sites, :jobshop_users, column: "owner_id",
5
+ on_delete: :restrict
6
+ end
7
+ end
@@ -9,11 +9,16 @@ module Jobshop
9
9
 
10
10
  def require_environment
11
11
  ENV['RAILS_ENV'] ||= "development"
12
- require File.expand_path("config/environment.rb")
12
+ abort "Please run this command within a Rails app." unless Rails.root
13
+
14
+ environment_filename = File.expand_path(
15
+ Rails.root + "config/environment.rb")
16
+
17
+ require environment_filename
13
18
  end
14
19
 
15
20
  def create_site
16
- @site = Jobshop::Site.new
21
+ @site = Jobshop::Site.create!(name: name)
17
22
  end
18
23
 
19
24
  def generate_token
@@ -26,8 +31,8 @@ module Jobshop
26
31
  # TODO: Give environments besides development a decent host and
27
32
  # protocol. HTTPS isn't mandatory in production but it is very, VERY
28
33
  # highly recommended.
29
- @link_text = Jobshop::Engine.routes.url_helpers.edit_site_url(
30
- @site,
34
+ @link_text = Jobshop::Engine.routes.url_helpers.
35
+ new_site_registration_url(@site,
31
36
  protocol: link_protocol,
32
37
  host: link_host,
33
38
  configuration_token: @token
@@ -0,0 +1,34 @@
1
+ module MemoAttr
2
+ private
3
+ def __memoized
4
+ @__memoized ||= {}
5
+ end
6
+
7
+ def self.included(mod)
8
+ mod.extend(ClassMethods)
9
+ end
10
+
11
+ module ClassMethods
12
+ def memo_attr(name, &block)
13
+ raise LocalJumpError.new('no block given') unless block_given?
14
+
15
+ instance_eval { define_memoized_method(name, &block) }
16
+ class_eval { define_validation_block(name) }
17
+ end
18
+
19
+ private
20
+ def define_memoized_method(name, &block)
21
+ define_method(name) do
22
+ __memoized.fetch(name) { |k| __memoized[k] = instance_eval(&block) }
23
+ end
24
+ end
25
+
26
+ def define_validation_block(name)
27
+ validate do
28
+ send(name).errors.each do |key, value|
29
+ errors.add("#{send(name).class.name.underscore}_#{key}", value)
30
+ end unless send(name).valid?
31
+ end
32
+ end
33
+ end
34
+ end
@@ -7,6 +7,17 @@ end
7
7
  remove_file "config/boot.rb"
8
8
  copy_file "boot.rb.tt", "config/boot.rb"
9
9
 
10
+ # The generated config/secrets.yml file uses hardcoded values for
11
+ # test/development environments. Generate secrets pragmatically.
12
+ remove_file "config/secrets.yml"
13
+ copy_file "secrets.yml.tt", "config/secrets.yml"
14
+
15
+ # The db/migrate folder never gets created for the dummy_app so do it manually.
16
+ unless Dir.exists?("db/migrate")
17
+ say_status :create, "db/migrate"
18
+ Dir.mkdir("db/migrate")
19
+ end
20
+
10
21
  route "mount Jobshop::Engine => \"/\""
11
22
 
12
23
  rake "db:create"
@@ -0,0 +1,38 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: <%=
15
+ path_to_key = File.expand_path("tmp/development_secret_key_base")
16
+ if File.exists?(path_to_key)
17
+ File.read(path_to_key).chomp
18
+ else
19
+ new_key = SecureRandom.hex(64)
20
+ File.write(path_to_key, new_key)
21
+ new_key
22
+ end %>
23
+
24
+ test:
25
+ secret_key_base: <%=
26
+ path_to_key = File.expand_path("tmp/test_secret_key_base")
27
+ if File.exists?(path_to_key)
28
+ File.read(path_to_key).chomp
29
+ else
30
+ new_key = SecureRandom.hex(64)
31
+ File.write(path_to_key, new_key)
32
+ new_key
33
+ end %>
34
+
35
+ # Do not keep production secrets in the repository,
36
+ # instead read values from the environment.
37
+ production:
38
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -7,7 +7,7 @@ module Jobshop
7
7
  MAJOR = 0
8
8
  MINOR = 0
9
9
  TINY = 4
10
- PRE = "0p1"
10
+ PRE = "0p13"
11
11
 
12
12
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
13
13
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobshop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.0p1
4
+ version: 0.0.4.0p13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank J. Mattia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-18 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coffee-rails
@@ -258,6 +258,20 @@ dependencies:
258
258
  - - "<"
259
259
  - !ruby/object:Gem::Version
260
260
  version: '3.6'
261
+ - !ruby/object:Gem::Dependency
262
+ name: shoulda-matchers
263
+ requirement: !ruby/object:Gem::Requirement
264
+ requirements:
265
+ - - "~>"
266
+ - !ruby/object:Gem::Version
267
+ version: '2.8'
268
+ type: :development
269
+ prerelease: false
270
+ version_requirements: !ruby/object:Gem::Requirement
271
+ requirements:
272
+ - - "~>"
273
+ - !ruby/object:Gem::Version
274
+ version: '2.8'
261
275
  - !ruby/object:Gem::Dependency
262
276
  name: web-console
263
277
  requirement: !ruby/object:Gem::Requirement
@@ -287,10 +301,12 @@ files:
287
301
  - app/assets/images/jobshop/logo.svg
288
302
  - app/assets/javascripts/jobshop/application.js
289
303
  - app/assets/stylesheets/jobshop/application.scss
304
+ - app/assets/stylesheets/jobshop/generics.scss
290
305
  - app/assets/stylesheets/jobshop/material-icons.scss
291
- - app/assets/stylesheets/jobshop/pages/index.scss
306
+ - app/assets/stylesheets/jobshop/site/configuration.scss
292
307
  - app/controllers/jobshop/application_controller.rb
293
308
  - app/controllers/jobshop/pages_controller.rb
309
+ - app/controllers/jobshop/sites/registrations_controller.rb
294
310
  - app/controllers/jobshop/sites_controller.rb
295
311
  - app/helpers/jobshop/application_helper.rb
296
312
  - app/jobs/jobshop/application_job.rb
@@ -298,8 +314,10 @@ files:
298
314
  - app/models/jobshop/site.rb
299
315
  - app/models/jobshop/user.rb
300
316
  - app/policies/jobshop/application_policy.rb
317
+ - app/resources/jobshop/application_resource.rb
318
+ - app/resources/jobshop/registration.rb
301
319
  - app/views/jobshop/pages/index.html.haml
302
- - app/views/jobshop/sites/edit.html.haml
320
+ - app/views/jobshop/sites/registrations/new.html.haml
303
321
  - app/views/layouts/jobshop/application.html.haml
304
322
  - config/initializers/assets.rb
305
323
  - config/initializers/devise.rb
@@ -307,6 +325,9 @@ files:
307
325
  - config/routes.rb
308
326
  - db/migrate/20160314122952_devise_create_jobshop_users.rb
309
327
  - db/migrate/20160314190424_create_jobshop_sites.rb
328
+ - db/migrate/20160321212058_add_site_id_to_users.rb
329
+ - db/migrate/20160321213638_add_foreign_key_for_site.rb
330
+ - db/migrate/20160322040604_add_owner_id_to_sites.rb
310
331
  - db/migrate/keep
311
332
  - lib/generators/jobshop/config/config_generator.rb
312
333
  - lib/generators/jobshop/config/templates/jobshop.rb.tt
@@ -316,8 +337,10 @@ files:
316
337
  - lib/jobshop.rb
317
338
  - lib/jobshop/dummy.rb
318
339
  - lib/jobshop/engine.rb
340
+ - lib/jobshop/support/memo_attr.rb
319
341
  - lib/jobshop/templates/boot.rb.tt
320
342
  - lib/jobshop/templates/dummy_template.rb
343
+ - lib/jobshop/templates/secrets.yml.tt
321
344
  - lib/jobshop/version.rb
322
345
  - lib/tasks/jobshop_tasks.rake
323
346
  homepage: https://jobshop.io
@@ -1,19 +0,0 @@
1
- html[data-controller="jobshop/pages"] {
2
- body[data-slug~="index"] {
3
- margin: 1rem;
4
-
5
- > header,
6
- > main,
7
- > footer {
8
- display: flex;
9
- flex-direction: column;
10
- justify-content: center;
11
- align-items: center;
12
-
13
- > section {
14
- width: 24rem;
15
- @media #{$small-and-down} { width: 100%; }
16
- }
17
- }
18
- }
19
- }
@@ -1,2 +0,0 @@
1
- %h1 Sites#edit
2
- %p Find me in app/views/jobshop/sites/edit.html.haml