thredded_create_app 0.1.3 → 0.1.4

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
  SHA1:
3
- metadata.gz: 8321129255513f386fad12a0d97ee42921986331
4
- data.tar.gz: 191f06d32b4a785fc7247f4727a680a813e6255f
3
+ metadata.gz: dfa3e7dfa51e502af97a906fb30679390fee8d2a
4
+ data.tar.gz: f12086e9db6afae849cb10bca6283088d61eccab
5
5
  SHA512:
6
- metadata.gz: 03e931cd479e9d3c1ae73b51ebf6885a28c2046d21744d60262daad28a04f18647a693f0d8b546e10cc377e3c62e561308fc08d9ffc3ffcd1aaa7fe53bcbb3c4
7
- data.tar.gz: 1275fc973cdfe0b1ab08510f3a1ffaeb3e478cf13d39dd46939c870dea6027e27b178ddc471a80bda6799f310cc0e624b6f13592bf7bc8bbe5de6ee50b5fac87
6
+ metadata.gz: ce92577653bd086b272dfb2ff406aaec2c88376bab0c8aa1bfb9828e4616f6b2b51a65c8cf831385f6783be58b54bd33bcc04df035027fc89f74e7602804352a
7
+ data.tar.gz: 9f1ae4bdcc9ca93e9bf7fbe9c9a438e14eaaa674320ce83e6bfa58d16cc8695fc82113aedf54ba03b31ec4aa867206162596128fc933c5841592441bea2e04c8
data/README.md CHANGED
@@ -102,8 +102,8 @@ This is so that other engineers can spin up a development environment with
102
102
  a single command.
103
103
 
104
104
  A production configuration file for the [puma] Ruby web server is created.
105
- A `Procfile` process description file that can be used by that can be used by
106
- the [Heroku] hosting platform or the [foreman] app runner is also be created.
105
+ A `Procfile` process description file is also created. This file can be used by
106
+ the [Heroku] hosting platform or the [foreman] app runner.
107
107
 
108
108
  Lastly, the `$APP` database user is created and given rights to the app's
109
109
  development and test databases. Then, the database is created, the migrations
@@ -78,10 +78,11 @@ module ThreddedCreateApp
78
78
  def bundle
79
79
  File.open('Gemfile', 'a') do |f|
80
80
  log_info 'Writing gems to Gemfile'
81
- gems.each do |(name, version, groups)|
81
+ gems.each do |(name, version, groups, path)|
82
82
  f.puts ["gem '#{name}'",
83
83
  (version if version),
84
- ("groups: %i(#{groups * ' '})" if groups)].compact.join(', ')
84
+ ("groups: %i(#{groups * ' '})" if groups),
85
+ ("path: '#{path}'" if path)].compact.join(', ')
85
86
  end
86
87
  end
87
88
  run "bundle install#{' --quiet' unless verbose?}"
@@ -31,6 +31,7 @@ module ThreddedCreateApp
31
31
  content: <<-'RUBY'
32
32
 
33
33
  before_action :store_current_location, unless: :devise_controller?
34
+ helper_method :back_url
34
35
 
35
36
  private
36
37
 
@@ -39,21 +40,26 @@ module ThreddedCreateApp
39
40
  end
40
41
 
41
42
  def after_sign_out_path_for(resource)
42
- request.referrer || root_path
43
+ stored_location_for(:user) || root_path
44
+ end
45
+
46
+ def back_url
47
+ session[:user_return_to] || root_path
43
48
  end
44
49
  RUBY
45
50
  end
46
51
 
47
52
  def setup_views
48
53
  run_generator 'devise:i18n:views -v sessions registrations'
54
+ # Replace the back link with the correct URL
55
+ replace 'app/views/devise/registrations/edit.html.erb',
56
+ ', :back %>', ', back_url %>'
49
57
  # Make the views render-able outside Devise controllers
50
- %w(app/views/devise/registrations/new.html.erb
51
- app/views/devise/registrations/edit.html.erb
52
- app/views/devise/sessions/new.html.erb
58
+ %w(app/views/devise/sessions/new.html.erb
53
59
  app/views/devise/shared/_links.html.erb).each do |path|
54
- replace path, 'resource_name', ':user'
55
- replace path, 'resource', ':user'
56
60
  replace path, 'resource_class', 'User', optional: true
61
+ replace path, /resource_name(?!:)/, ':user'
62
+ replace path, /resource(?!:)/, ':user', optional: true
57
63
  replace path, 'devise_mapping', 'Devise.mappings[:user]',
58
64
  optional: true
59
65
  end
@@ -5,10 +5,10 @@ class AddDisplayNameToUsers < ActiveRecord::Migration[5.0]
5
5
  when /mysql/i
6
6
  add_column :users, :display_name, :string, limit: 191
7
7
  when /sqlite/i
8
- add_column :users, :display_name, :text
8
+ add_column :users, :display_name, :string
9
9
  change_column_null :users, :display_name, false
10
10
  else
11
- add_column :users, :display_name, :text, null: false
11
+ add_column :users, :display_name, :string, null: false
12
12
  end
13
13
 
14
14
  DbTextSearch::CaseInsensitive.add_index connection, :users, :display_name,
@@ -2,6 +2,7 @@
2
2
 
3
3
  $thredded-brand: $brand-primary;
4
4
  $thredded-text-color: $text-color;
5
+ $thredded-secondary-text-color: $secondary-text-color;
5
6
  $thredded-base-font-family: $base-font-family;
6
7
  $thredded-base-font-size: $base-font-size;
7
8
  $thredded-base-line-height: $base-line-height;
@@ -29,9 +29,9 @@ module ThreddedCreateApp
29
29
 
30
30
  protected
31
31
 
32
- def add_gem(gem_name, version: nil, groups: nil)
32
+ def add_gem(gem_name, version: nil, groups: nil, path: nil)
33
33
  log_verbose "+ gem #{gem_name}"
34
- @gems << [gem_name, version, groups]
34
+ @gems << [gem_name, version, groups, path]
35
35
  end
36
36
 
37
37
  def git_commit(message)
@@ -1,5 +1,6 @@
1
1
  $brand-primary: <%= brand_primary %>;
2
2
  $text-color: #575d6b;
3
+ $secondary-text-color: lighten($text-color, 30%);
3
4
  $base-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
4
5
  $base-font-size: 1rem;
5
6
  $base-line-height: 1.5;
@@ -1,7 +1,18 @@
1
1
  <body class="app">
2
- <div class="app-container">
2
+ <% is_thredded = content_for?(:thredded_page_id) %>
3
+ <%= content_tag :div,
4
+ class: 'app-container',
5
+ id: ('app-page-container' unless is_thredded) do %>
3
6
  <%= render 'shared/header' %>
4
- <%= render 'shared/flash_messages' unless content_for?(:thredded_page_id) %>
7
+ <%= render 'shared/flash_messages' unless is_thredded %>
5
8
  <div class="app-content-container"><%= yield %></div>
6
- </div>
9
+ <%# If thredded JS is loaded via an [async] script, the JS may
10
+ run before or after DOMContentLoaded. Expose a flag to Thredded
11
+ so it can initialize correctly. %>
12
+ <script data-turbolinks-eval="false">
13
+ document.addEventListener('DOMContentLoaded', function() {
14
+ (window.App = window.App || {}).DOMContentLoadedFired = true;
15
+ });
16
+ </script>
17
+ <% end %>
7
18
  </body>
@@ -58,6 +58,19 @@
58
58
  margin: 1rem 0;
59
59
  }
60
60
 
61
+ .form-inputs {
62
+ .hint {
63
+ color: $secondary-text-color;
64
+ }
65
+ .error {
66
+ @extend %thredded--alert;
67
+ @extend %thredded--alert--danger;
68
+ display: block;
69
+ border-top-left-radius: 0;
70
+ border-top-right-radius: 0;
71
+ }
72
+ }
73
+
61
74
  a {
62
75
  @extend %thredded--link;
63
76
  }
@@ -8,10 +8,21 @@ end
8
8
  # @return [String] html_safe datetime presentation
9
9
  def time_ago(datetime, default: '-')
10
10
  timeago_tag datetime,
11
- lang: I18n.locale.to_s.downcase,
12
- format: (lambda do |t, _opts|
11
+ lang: I18n.locale.to_s.downcase,
12
+ format: (lambda do |t, _opts|
13
13
  t.year == Time.current.year ? :short : :long
14
14
  end),
15
- nojs: true,
15
+ nojs: true,
16
+ date_only: false,
16
17
  default: default
17
18
  end
19
+
20
+ # Override the default timeago_tag_content from rails-timeago
21
+ def timeago_tag_content(time, time_options = {})
22
+ if time_options[:nojs] &&
23
+ (time_options[:limit].nil? || time_options[:limit] < time)
24
+ t 'common.time_ago', time: time_ago_in_words(time)
25
+ else
26
+ I18n.l time.to_date, format: time_options[:format]
27
+ end
28
+ end
@@ -1,7 +1,10 @@
1
1
  en:
2
2
  brand:
3
3
  name: <%= app_name.tr('_', ' ').capitalize %>
4
+ common:
5
+ time_ago: "%{time} ago"
4
6
  nav:
7
+ edit_my_account: Edit my account
5
8
  forums: :thredded.nav.all_messageboards
6
9
  sign_in: :devise.shared.links.sign_in
7
10
  sign_out: Sign out
@@ -0,0 +1,13 @@
1
+ //= require jquery.timeago
2
+ (function () {
3
+ if (!this.App.isAppPage()) {
4
+ return;
5
+ }
6
+ var COMPONENT_SELECTOR = '[data-time-ago]';
7
+ this.App.onPageLoad(function () {
8
+ const allowFutureWas = jQuery.timeago.settings.allowFuture;
9
+ jQuery.timeago.settings.allowFuture = true;
10
+ jQuery(COMPONENT_SELECTOR).timeago();
11
+ jQuery.timeago.settings.allowFuture = allowFutureWas;
12
+ });
13
+ }).call(this);
@@ -0,0 +1,53 @@
1
+ //= require_self
2
+ //= require_tree ./app
3
+
4
+ (function () {
5
+ this.App = this.App || {};
6
+ var App = this.App;
7
+
8
+ var isTurbolinks = 'Turbolinks' in window && window.Turbolinks.supported;
9
+ var isTurbolinks5 = isTurbolinks && 'clearCache' in window.Turbolinks;
10
+
11
+ var onPageLoadFiredOnce = false;
12
+ var pageLoadCallbacks = [];
13
+ var triggerOnPageLoad = function () {
14
+ pageLoadCallbacks.forEach(function (callback) {
15
+ callback();
16
+ });
17
+ onPageLoadFiredOnce = true;
18
+ };
19
+
20
+ // Fires the callback on DOMContentLoaded or a Turbolinks page load.
21
+ // If called from an async script on the first page load, and the DOMContentLoad event
22
+ // has already fired, will execute the callback immediately.
23
+ App.onPageLoad = function (callback) {
24
+ pageLoadCallbacks.push(callback);
25
+ // With async script loading, a callback may be added after the DOMContentLoaded event has already triggered.
26
+ // This means we will receive neither a DOMContentLoaded event, nor a turbolinks:load event on Turbolinks 5.
27
+ if (!onPageLoadFiredOnce && App.DOMContentLoadedFired) {
28
+ callback();
29
+ }
30
+ };
31
+
32
+ if (isTurbolinks5) {
33
+ document.addEventListener('turbolinks:load', function () {
34
+ triggerOnPageLoad();
35
+ });
36
+ } else {
37
+ // Turbolinks Classic (with or without jQuery.Turbolinks), or no Turbolinks:
38
+ if (!App.DOMContentLoadedFired) {
39
+ document.addEventListener('DOMContentLoaded', function () {
40
+ triggerOnPageLoad();
41
+ });
42
+ }
43
+ if (isTurbolinks) {
44
+ document.addEventListener('page:load', function () {
45
+ triggerOnPageLoad();
46
+ })
47
+ }
48
+ }
49
+
50
+ App.isAppPage = function() {
51
+ return !!document.getElementById('app-page-container');
52
+ }
53
+ }).call(this);
@@ -6,6 +6,9 @@
6
6
  <%= image_tag Thredded.avatar_url.call(user), class: 'thredded--user--avatar' %><%= user.thredded_display_name %>
7
7
  </h1>
8
8
  <ul>
9
+ <% if user == current_user %>
10
+ <%= link_to t('nav.edit_my_account'), edit_user_registration_path %>
11
+ <% end %>
9
12
  <li><%= t 'thredded.users.user_since_html', time_ago: time_ago(user.created_at) %></li>
10
13
  <% if user_detail.last_seen_at %>
11
14
  <li><%= t 'thredded.users.last_active_html', time_ago: time_ago(user_detail.last_seen_at) %></li>
@@ -59,6 +59,11 @@ module ThreddedCreateApp
59
59
  replace 'app/assets/javascripts/application.js',
60
60
  %r{^//= require jquery$},
61
61
  '//= require jquery3'
62
+
63
+ copy 'setup_app_skeleton/javascripts/app.js',
64
+ 'app/assets/javascripts/app.js'
65
+ copy 'setup_app_skeleton/javascripts/app/time_ago.js',
66
+ 'app/assets/javascripts/app/time_ago.js'
62
67
  git_commit 'Use jQuery v3 instead of jQuery v1'
63
68
  end
64
69
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ThreddedCreateApp
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thredded_create_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gleb Mazovetskiy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: term-ansicolor
@@ -140,6 +140,8 @@ files:
140
140
  - lib/thredded_create_app/tasks/setup_app_skeleton/application_helper_methods.rb
141
141
  - lib/thredded_create_app/tasks/setup_app_skeleton/en.yml.erb
142
142
  - lib/thredded_create_app/tasks/setup_app_skeleton/home_show.html.erb.erb
143
+ - lib/thredded_create_app/tasks/setup_app_skeleton/javascripts/app.js
144
+ - lib/thredded_create_app/tasks/setup_app_skeleton/javascripts/app/time_ago.js
143
145
  - lib/thredded_create_app/tasks/setup_app_skeleton/seeds.rb.erb
144
146
  - lib/thredded_create_app/tasks/setup_app_skeleton/spec/controllers/users_controller_spec.rb
145
147
  - lib/thredded_create_app/tasks/setup_app_skeleton/spec/features/homepage_spec.rb