codeword 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2a3032588df8a3dfcb5b5584785cdc9edf5558f2a47216dc70e32a74c083720
4
- data.tar.gz: 54dcd07135dd8fe40e1a09091894a7c9baffb9c91d30e0bb4e12f0c18d3686ff
3
+ metadata.gz: 0df77c174f33909ed5e7f6b4168485dea5e4888098f2ca4c41c576b60b4da44a
4
+ data.tar.gz: f0d1971d5214427371119fac86d8c63e0e40b76a23682a3cd766029e7e275460
5
5
  SHA512:
6
- metadata.gz: 811c21657b493979a64f641e3cb042bae1aec61312d7a3a96e45d7ac17614fcb0fa438f24cb8d7f75c75ef75279082018cb8b9bb97842c0542d2568693994bab
7
- data.tar.gz: b3066b27282c5d060c981aa25f983f72fbe51144c31b7aee85921009696c66914976f404c3b6371fc7d1eef39e2e8f081bd87e356c3bf89a6c3bf71c6b35f283
6
+ metadata.gz: b833d1f568e8c6e1b138b42ec0b80c2645c4def43e22b3b362fa0078d285f50a0c84efe571bd213fc81e87a666f0d0dc15a6c9a69e0e94360ec85f033b47a94b
7
+ data.tar.gz: 892591cc8b6feecccee50e0b6e084fb01f3f991f2eb21d23cef9f20a3177d517854964911c9eda0b79f7196cc76573732e01c39ee372719544a9030f5c0c11cc
data/CHANGELOG.md ADDED
@@ -0,0 +1,10 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.1] - 2021-12-17
4
+
5
+ - Fix unlocks
6
+ - Refactor CodewordController
7
+
8
+ ## [0.1.0] - 2021-12-17
9
+
10
+ - Initial release
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Codeword
2
2
 
3
- A simple gem to more elegantly place a staging server or other in-progress rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet.
3
+ A simple gem to more elegantly place a staging server or other in-progress rails application behind a basic codeword. It’s easy to implement, share with clients/collaborators, and more beautiful than the typical password-protection sheet. This is a fork of [lockup](https://github.com/interdiscipline/lockup).
4
4
 
5
5
  ## Installation
6
6
 
@@ -94,4 +94,16 @@ cookie_lifetime_in_weeks: 4
94
94
 
95
95
  ### Design Customization
96
96
 
97
- If you would like to change the content or design of the codeword page, you can create the directories `app/views/layouts/codeword` and `app/views/codeword/codeword` and populate them with the default content from [here](https://github.com/gblakeman/codeword/tree/master/app/views), and then customize as desired.
97
+ If you would like to change the content or design of the codeword page, you can create the directories `app/views/layouts/codeword` and `app/views/codeword/codeword` and populate them with the default content from [here](https://github.com/dankimio/codeword/tree/main/app/views), and then customize as desired.
98
+
99
+ ## Development
100
+
101
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
102
+
103
+ ## Contributing
104
+
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/dankimio/codeword.
106
+
107
+ ## License
108
+
109
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -2,38 +2,23 @@ module Codeword
2
2
  class CodewordController < Codeword::ApplicationController
3
3
  CRAWLER_REGEX = /crawl|googlebot|slurp|spider|bingbot|tracker|click|parser|spider/
4
4
 
5
- if respond_to?(:skip_before_action)
6
- skip_before_action :check_for_codeword
7
- else
8
- skip_before_filter :check_for_codeword
9
- end
5
+ skip_before_action :check_for_codeword
10
6
 
11
7
  def unlock
12
- if params[:codeword].present?
13
- user_agent = request.env['HTTP_USER_AGENT'].presence
14
- if user_agent && user_agent.downcase.match(CRAWLER_REGEX)
15
- head :ok
16
- return
17
- end
8
+ user_agent = request.env['HTTP_USER_AGENT'].presence
9
+ if user_agent && user_agent.downcase.match(CRAWLER_REGEX)
10
+ head :ok
11
+ return
12
+ end
18
13
 
14
+ if params[:codeword].present?
19
15
  @codeword = params[:codeword].to_s.downcase
20
16
  @return_to = params[:return_to]
21
- if @codeword == codeword.to_s.downcase
17
+ if @codeword == codeword_code.to_s.downcase
22
18
  set_cookie
23
19
  run_redirect
24
- end
25
- elsif request.post?
26
- if params[:codeword].present? && params[:codeword].respond_to?(:'[]')
27
- @codeword = params[:codeword][:codeword].to_s.downcase
28
- @return_to = params[:codeword][:return_to]
29
- if @codeword == codeword.to_s.downcase
30
- set_cookie
31
- run_redirect
32
- else
33
- @wrong = true
34
- end
35
20
  else
36
- head :ok
21
+ @wrong = true
37
22
  end
38
23
  else
39
24
  respond_to :html
@@ -9,17 +9,17 @@
9
9
  </div>
10
10
  <% end %>
11
11
 
12
- <%= form_for :codeword, url: { action: 'unlock' } do |form| %>
12
+ <%= form_tag '/codeword/unlock' do %>
13
13
  <% if params[:return_to].present? %>
14
- <%= form.hidden_field "return_to", value: params[:return_to] %>
14
+ <%= hidden_field_tag 'return_to', params[:return_to] %>
15
15
  <% elsif @return_to.present? %>
16
- <%= form.hidden_field "return_to", value: @return_to %>
16
+ <%= hidden_field_tag 'return_to', @return_to %>
17
17
  <% end %>
18
18
 
19
19
  <% unless @wrong == true %>
20
- <%= form.password_field :codeword, placeholder: "Code word", autofocus: true, required: true %>
20
+ <%= password_field_tag 'codeword', nil, placeholder: "Code word", autofocus: true, required: true %>
21
21
  <% else %>
22
- <%= form.password_field :codeword, value: @codeword, class: 'nope', autofocus: true, required: true %>
22
+ <%= password_field_tag 'codeword', @codeword, class: 'nope', autofocus: true, required: true %>
23
23
  <% end %>
24
24
 
25
25
  <% if codeword_hint %>
@@ -2,12 +2,6 @@ module Codeword
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace Codeword
4
4
 
5
- config.generators do |g|
6
- g.test_framework :rspec, fixture: false
7
- g.assets false
8
- g.helper false
9
- end
10
-
11
5
  initializer 'codeword.app_controller' do |_app|
12
6
  ActiveSupport.on_load(:action_controller) { include Codeword }
13
7
  end
@@ -1,3 +1,3 @@
1
1
  module Codeword
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/codeword.rb CHANGED
@@ -6,11 +6,7 @@ module Codeword
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  included do
9
- if respond_to?(:before_action)
10
- before_action :check_for_codeword, except: ['unlock']
11
- else
12
- before_filter :check_for_codeword, except: ['unlock']
13
- end
9
+ before_action :check_for_codeword, except: ['unlock']
14
10
  end
15
11
 
16
12
  def self.from_config(setting, secrets_or_credentials = :credentials)
@@ -44,7 +40,7 @@ module Codeword
44
40
  end
45
41
 
46
42
  def codeword_code
47
- @codeword ||=
43
+ @codeword_code ||=
48
44
  ENV['CODEWORD'] ||
49
45
  ENV['codeword'] ||
50
46
  Codeword.from_config(:codeword, :secrets) ||
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: codeword
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Kim
@@ -92,6 +92,7 @@ extra_rdoc_files: []
92
92
  files:
93
93
  - ".gitignore"
94
94
  - ".ruby-version"
95
+ - CHANGELOG.md
95
96
  - Gemfile
96
97
  - LICENSE.txt
97
98
  - README.md