97 Commits 5f485e64fa ... 012b2e89f0

Author SHA1 Message Date
  ANX 5f485e64fa fix: readme 6 years ago
  ANX e104460102 Initial Commit 6 years ago
  Chris Oliver 012b2e89f0 Fix password syntax 6 years ago
  Chris Oliver a2ffcbb047 Merge branch 'master' of github.com:excid3/spark-clone 6 years ago
  Chris Oliver 1ebcda7065 Migrate user names to basecamp/name_of_person 6 years ago
  Chris Oliver d986efa852 Add trailing comma 6 years ago
  Mario Zigliotto a2547862ab Make Application helpers accessible to Administrate (#60) 6 years ago
  Chris Oliver cbd5726e34 Disable search on password field 6 years ago
  Chris Oliver a3c9d9c3eb Remove Devise trackable 6 years ago
  Mario Zigliotto a4782529e7 Fix missing translation error (#56) 6 years ago
  Chris Oliver 2a4329baba Add requirements list. Closes #55 6 years ago
  Chris Oliver 1f1a6cc9f2 Merge branch 'master' of github.com:excid3/jumpstart 6 years ago
  Chris Oliver 964c5f6260 Include masquerade_user. Fixes #53 6 years ago
  flprben 59a8d26073 Fix wrong number of arguments error in icon in Masquerade (#52) 6 years ago
  Chris Oliver c0d18ac2b8 Merge branch 'master' of github.com:excid3/spark-clone 6 years ago
  Chris Oliver c5d3193ca4 Update gems and add local_time 6 years ago
  Chris Oliver 62f80f51e8 Merge branch 'master' of github.com:excid3/jumpstart 6 years ago
  Chris Oliver 350df372f4 Add link back to app in admin navigation 6 years ago
  Chris Oliver aea6b4e0ee Configure ActionCable to authenticate with Devise and use Redis by default 6 years ago
  Chris Oliver 3e08b2f29f Update Administrate dependency 6 years ago
  Pat Conley 42fa025ee5 add pswd to user dash (#47) 6 years ago
  William Kennedy d538d2e5b3 Added sitemap generator (#50) 6 years ago
  darkrubyist ce69db531a Add Rails 5.2 Version to Friendly Id Migration (#51) 6 years ago
  darkrubyist a24ddfc021 Add Friendly Id (#45) 6 years ago
  Chris Oliver 8ddc352422 Merge branch 'master' of github.com:excid3/spark-clone 6 years ago
  Chris Oliver dcda308c7e Update webpacker 6 years ago
  Kai Rautenberg f71ffd0140 +stop spring before devise generator runs (#43) 6 years ago
  Chris Oliver 43ba3d16f2 Update notification.rb 6 years ago
  darkrubyist 716ca1f51c Add unread notification scope. (#41) 6 years ago
  Chris Oliver 40048c9afc Add requires 6 years ago
  Chris Oliver 6e18e7c748 Clone a local copy of the repo if run through https 6 years ago
  darkrubyist 2927234e79 Application name based on Rails folder name (#37) 6 years ago
  Chris Oliver d3f35484ac Update template.rb 6 years ago
  Chris Oliver ddced9025b Update README.md 6 years ago
  Chris Oliver 41f0e58861 Copy over the lib directory to new apps 6 years ago
  Chris Oliver ddcb38bef4 Add data-confirm-modal 6 years ago
  Chris Oliver 63d6cd3bd0 Add some basic scaffold overrides that use Bootstrap 6 years ago
  darkrubyist 3dbe1cb4bf Change Title with the application name. (#34) 6 years ago
  darkrubyist 4a733a8a88 Change Logo with Application Name (#33) 6 years ago
  darkrubyist 18665e289b Ask user for application name and set it global (#35) 6 years ago
  William Kennedy 54fabb94f2 Updated template to use Rails 5.2 and added whenever gem (#32) 6 years ago
  darkrubyist 076c3ccc63 Update Devise to latest version. (#30) 6 years ago
  Chris Oliver 4afd959fff Create LICENSE (#31) 6 years ago
  Chris Oliver 21855e1ed4 Few more tweaks 6 years ago
  Chris Oliver 18e6b8ac48 Rename 6 years ago
  Chris Oliver 5741eb0017 Tweak devise and administrate 6 years ago
  Chris Oliver 9446a5702c Update README.md 6 years ago
  Chris Oliver 3b3ba820d4 Update user.rb 7 years ago
  Chris Oliver 1e43739c10 Fix name fields 7 years ago
  Miguel 15c5713b04 Merge pull request #24 from mickeytgl/master 7 years ago
  Chris Oliver af60abd4ed Merge branch 'master' of github.com:excid3/spark-clone 7 years ago
  Chris Oliver 82f669f951 Copy templates before migrations 7 years ago
  Miguel 031ddb9a04 Omniauth line in devise.rb if keys are present (#22) 7 years ago
  Miguel 12c8c759c9 Fix user migration - single name field 7 years ago
  Miguel e54cb4444d Omniauth line in devise.rb if keys are present 7 years ago
  Chris Oliver e0df5b2b9b Directly added omniauthable to app/models/user.rb 7 years ago
  Chris Oliver 979f17a566 Include services on user 7 years ago
  Chris Oliver dcd6ae54a5 Scope notifications controller to the current user 7 years ago
  Chris Oliver 18ed1676bf Use notifiable type as a scope for partial names 7 years ago
  Scott Christensen f187fcd7c0 Notifications (#19) 7 years ago
  Chris Oliver 23d5ce4984 Add omniauthable. Fixes #18 7 years ago
  Miguel a5c9d555d1 Twitter, Facebook, GitHub sign up (#16) 7 years ago
  Chris Oliver 0975ff696e Validate names are present 7 years ago
  Scott Christensen 9146494bae add name fields to devise registrations (#15) 7 years ago
  Chris Oliver 91b46489d3 Update README.md 7 years ago
  Chris Oliver 4a3eaa41ed Fix merge 7 years ago
  Chris Oliver d0682e9121 More bootstrap beta fixes 7 years ago
  Chris Oliver dbc7671620 Update to bootstrap 4 beta 7 years ago
  Chris Oliver 6195772214 Bootstrap beta 7 years ago
  Chris Oliver 10cf0a4337 Add masquerading 7 years ago
  Chris Oliver 5978068084 Clean up some css 7 years ago
  Chris Oliver 213df0d0ad Fix announcements column name and add empty placeholder 7 years ago
  Chris Oliver 43306e2782 Add container and better control over notices 7 years ago
  Chris Oliver 182c4d683e update administrate and devise to Rails 5.1 compat 7 years ago
  Chris Oliver 2b18182d91 Add administrate #10 7 years ago
  Chris Oliver 419a84f946 Improve all the devise stuff 7 years ago
  Chris Oliver 2dd44369bf Use @king601's devise bootstrapped instead of rails devise views 7 years ago
  Chris Oliver 5e06725983 Add announcements. Closes #2 7 years ago
  Chris Oliver bded193021 Add terms and privacy and navigation and footer 7 years ago
  Chris Oliver f4ac0cc074 Don't scope views as that will be a lot more normal for users 7 years ago
  Chris Oliver 394722a2de Add viewport and utf8 meta tags 7 years ago
  Chris Oliver 02b100a6fc Add devise bootstrapped and bootstrap's tether 7 years ago
  Chris Oliver 9af0ec8a9e Temporarily use devise from master until it's released 7 years ago
  Chris Oliver bf13e22158 Add Sidekiq Web UI that's locked down to admins only. Fixes #9 7 years ago
  Chris Oliver 7e5b99e202 Merge branch 'master' of github.com:excid3/spark-clone 7 years ago
  Chris Oliver dcaa797f0b Add admin boolean to users and default it to false 7 years ago
  Jason Charnes efb8c4a76d Replaces Boostrap 3 with Bootstrap 4 7 years ago
  Jason Charnes caac59fcdc Adds Bootstrap JS and some CSS examples 7 years ago
  Jason Charnes 14221dd3a6 Replaces application.css with application.scss 7 years ago
  Chris Oliver b24e7c435b Refactor a bit. Adds Sidekiq, Webpacker, and Foreman. 7 years ago
  Jason Charnes 806c45d49f Ignore DS_Store 7 years ago
  Jason Charnes ce968d581a Adds Bootstrap gem 7 years ago
  Jason Charnes b1f2eb981b Merge pull request #7 from excid3/devise 7 years ago
  Jason Charnes 41c8865459 Adds Devise and User 7 years ago
  Chris Oliver a7e991c04d Update README.md 7 years ago
  Jason Charnes 5dfcac13c3 Create README.md 7 years ago
  Jason Charnes 9b276cd5f1 Initialize with template.rb 7 years ago

+ 1 - 1
LICENSE

@@ -1,6 +1,6 @@
 MIT License
 MIT License
 
 
-Copyright (c) 2018 Ivan Chen
+Copyright (c) 2018 Chris Oliver
 
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 of this software and associated documentation files (the "Software"), to deal

+ 1 - 1
Procfile

@@ -1,3 +1,3 @@
 web: rails server
 web: rails server
 sidekiq: sidekiq
 sidekiq: sidekiq
-webpack: bin/webpack-dev-server
+webpack: bin/webpack-dev-server

+ 2 - 7
README.md

@@ -20,13 +20,13 @@ You'll need the following installed to run the template successfully:
 #### Creating a new app
 #### Creating a new app
 
 
 ```bash
 ```bash
-rails new myapp -d postgresql -m http://gogs.anxgang.com/Hiskio/jumpstart/raw/master/template.rb --skip-coffee --skip-test
+rails new myapp -d postgresql -m https://raw.githubusercontent.com/excid3/jumpstart/master/template.rb
 ```
 ```
 
 
 Or if you have downloaded this repo, you can reference template.rb locally:
 Or if you have downloaded this repo, you can reference template.rb locally:
 
 
 ```bash
 ```bash
-rails new myapp -d postgresql -m template.rb --skip-coffee --skip-test
+rails new myapp -d postgresql -m template.rb
 ```
 ```
 
 
 #### Cleaning up
 #### Cleaning up
@@ -37,8 +37,3 @@ spring stop
 cd ..
 cd ..
 rm -rf myapp
 rm -rf myapp
 ```
 ```
-
-#### Stimulus (Options)
-```
-$ rake webpacker:install:stimulus
-```

+ 21 - 0
app/assets/stylesheets/announcements.scss

@@ -0,0 +1,21 @@
+.announcement {
+  strong {
+    color: $gray-700;
+    font-weight: 900;
+  }
+}
+
+.unread-announcements:before {
+  -moz-border-radius: 50%;
+  -webkit-border-radius: 50%;
+  border-radius: 50%;
+  -moz-background-clip: padding-box;
+  -webkit-background-clip: padding-box;
+  background-clip: padding-box;
+  background: $red;
+  content: '';
+  display: inline-block;
+  height: 8px;
+  width: 8px;
+  margin-right: 6px;
+}

+ 7 - 0
app/controllers/notifications_controller.rb

@@ -0,0 +1,7 @@
+class NotificationsController < ApplicationController
+  before_action :authenticate_user!
+
+  def index
+    @notifications = current_user.notifications
+  end
+end

+ 19 - 0
app/helpers/announcements_helper.rb

@@ -0,0 +1,19 @@
+module AnnouncementsHelper
+  def unread_announcements(user)
+    last_announcement = Announcement.order(published_at: :desc).first
+    return if last_announcement.nil?
+
+    # Highlight announcements for anyone not logged in, cuz tempting
+    if user.nil? || user.announcements_last_read_at.nil? || user.announcements_last_read_at < last_announcement.published_at
+      "unread-announcements"
+    end
+  end
+
+  def announcement_class(type)
+    {
+      "new" => "text-success",
+      "update" => "text-warning",
+      "fix" => "text-danger",
+    }.fetch(type, "text-success")
+  end
+end

+ 13 - 0
app/models/announcement.rb

@@ -0,0 +1,13 @@
+class Announcement < ApplicationRecord
+  TYPES = %w{ new fix update }
+
+  after_initialize :set_defaults
+
+  validates :announcement_type, :description, :name, :published_at, presence: true
+  validates :announcement_type, inclusion: { in: TYPES }
+
+  def set_defaults
+    self.published_at      ||= Time.zone.now
+    self.announcement_type ||= TYPES.first
+  end
+end

+ 25 - 0
app/models/notification.rb

@@ -0,0 +1,25 @@
+class Notification < ApplicationRecord
+  belongs_to :recipient, class_name: "User"
+  belongs_to :actor, class_name: "User"
+  belongs_to :notifiable, polymorphic: true
+  
+  scope :unread, -> { where(read_at: nil) }
+  scope :recent, -> { order(created_at: :desc).limit(5) }
+
+  def self.post(to:, from:, action:, notifiable:)
+    recipients = Array.wrap(to)
+    notifications = []
+
+    Notification.transaction do
+      notifications = recipients.uniq.each do |recipient|
+        Notification.create(
+          notifiable: notifiable,
+          action:     action,
+          recipient:  recipient,
+          actor:      from
+        )
+      end
+    end
+    notifications
+  end
+end

+ 4 - 1
app/models/user.rb

@@ -1,7 +1,10 @@
 class User < ApplicationRecord
 class User < ApplicationRecord
   # Include default devise modules. Others available are:
   # Include default devise modules. Others available are:
   # :confirmable, :lockable, :timeoutable and :omniauthable
   # :confirmable, :lockable, :timeoutable and :omniauthable
-  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :omniauthable
+  devise :masqueradable, :database_authenticatable, :registerable, :recoverable, :rememberable, :validatable, :omniauthable
 
 
+  has_person_name
+
+  has_many :notifications, foreign_key: :recipient_id
   has_many :services
   has_many :services
 end
 end

+ 28 - 0
app/views/announcements/index.html.erb

@@ -0,0 +1,28 @@
+<h1>What's New</h1>
+
+<div class="card">
+  <div class="card-body">
+    <% @announcements.each_with_index do |announcement, index| %>
+      <% if index != 0 %>
+        <div class="row"><div class="col"><hr /></div></div>
+      <% end %>
+
+      <div class="row announcement" id="<%= dom_id(announcement) %>">
+        <div class="col-sm-1 text-center">
+          <%= link_to announcements_path(anchor: dom_id(announcement)) do %>
+            <strong><%= announcement.published_at.strftime("%b %d") %></strong>
+          <% end %>
+        </div>
+        <div class="col">
+          <strong class="<%= announcement_class(announcement.announcement_type) %>"><%= announcement.announcement_type.titleize %>:</strong>
+          <strong><%= announcement.name %></strong>
+          <%= simple_format announcement.description %>
+        </div>
+      </div>
+    <% end %>
+
+    <% if @announcements.empty? %>
+      <div>Exciting stuff coming very soon!</div>
+    <% end %>
+  </div>
+</div>

+ 7 - 0
app/views/notifications/index.html.erb

@@ -0,0 +1,7 @@
+<h1>Notifications</h1>
+
+<ul>
+  <% @notifications.each do |notification| %>
+    <li><%= render "notifications/#{notification.notifiable_type.underscore}/#{notification.action.underscore}", actor: notification.actor, notifiable: notification.notifiable  %></li>
+  <% end %>
+</ul>

+ 84 - 6
template.rb

@@ -13,7 +13,7 @@ def add_template_repository_to_source_path
     at_exit { FileUtils.remove_entry(tempdir) }
     at_exit { FileUtils.remove_entry(tempdir) }
     git clone: [
     git clone: [
       "--quiet",
       "--quiet",
-      "http://gogs.anxgang.com/Hiskio/jumpstart.git",
+      "https://github.com/excid3/jumpstart.git",
       tempdir
       tempdir
     ].map(&:shellescape).join(" ")
     ].map(&:shellescape).join(" ")
 
 
@@ -26,19 +26,27 @@ def add_template_repository_to_source_path
 end
 end
 
 
 def add_gems
 def add_gems
+  gem 'administrate', '~> 0.10.0'
   gem 'bootstrap', '~> 4.1', '>= 4.1.1'
   gem 'bootstrap', '~> 4.1', '>= 4.1.1'
-  gem 'devise', '~> 4.5', '>= 4.4.3'
+  gem 'data-confirm-modal', '~> 1.6', '>= 1.6.2'
+  gem 'devise', '~> 4.4', '>= 4.4.3'
   gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'
   gem 'devise-bootstrapped', github: 'excid3/devise-bootstrapped', branch: 'bootstrap4'
+  gem 'devise_masquerade', '~> 0.6.2'
   gem 'font-awesome-sass', '~> 5.0', '>= 5.0.13'
   gem 'font-awesome-sass', '~> 5.0', '>= 5.0.13'
+  gem 'foreman', '~> 0.84.0'
+  gem 'friendly_id', '~> 5.2', '>= 5.2.4'
   gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'
   gem 'gravatar_image_tag', github: 'mdeering/gravatar_image_tag'
   gem 'jquery-rails', '~> 4.3.1'
   gem 'jquery-rails', '~> 4.3.1'
+  gem 'local_time', '~> 2.0', '>= 2.0.1'
   gem 'mini_magick', '~> 4.8'
   gem 'mini_magick', '~> 4.8'
+  gem 'name_of_person', '~> 1.0'
   gem 'omniauth-facebook', '~> 5.0'
   gem 'omniauth-facebook', '~> 5.0'
   gem 'omniauth-github', '~> 1.3'
   gem 'omniauth-github', '~> 1.3'
   gem 'omniauth-twitter', '~> 1.4'
   gem 'omniauth-twitter', '~> 1.4'
   gem 'sidekiq', '~> 5.1', '>= 5.1.3'
   gem 'sidekiq', '~> 5.1', '>= 5.1.3'
+  gem 'sitemap_generator', '~> 6.0', '>= 6.0.1'
   gem 'webpacker', '~> 3.5', '>= 3.5.3'
   gem 'webpacker', '~> 3.5', '>= 3.5.3'
-  gem 'procodile', '~> 1.0', '>= 1.0.16'
+  gem 'whenever', require: false
 end
 end
 
 
 def set_application_name
 def set_application_name
@@ -82,6 +90,9 @@ def add_users
       /  # config.secret_key = .+/,
       /  # config.secret_key = .+/,
       "  config.secret_key = Rails.application.credentials.secret_key_base"
       "  config.secret_key = Rails.application.credentials.secret_key_base"
   end
   end
+
+  # Add Devise masqueradable to users
+  inject_into_file("app/models/user.rb", "omniauthable, :masqueradable, :", after: "devise :")
 end
 end
 
 
 def add_bootstrap
 def add_bootstrap
@@ -107,7 +118,6 @@ end
 
 
 def add_webpack
 def add_webpack
   rails_command 'webpacker:install'
   rails_command 'webpacker:install'
-  # rails_command 'webpacker:install:stimulus'
 end
 end
 
 
 def add_sidekiq
 def add_sidekiq
@@ -122,10 +132,50 @@ def add_sidekiq
     after: "Rails.application.routes.draw do\n"
     after: "Rails.application.routes.draw do\n"
 end
 end
 
 
-def add_procodile
+def add_foreman
   copy_file "Procfile"
   copy_file "Procfile"
 end
 end
 
 
+def add_announcements
+  generate "model Announcement published_at:datetime announcement_type name description:text"
+  route "resources :announcements, only: [:index]"
+end
+
+def add_notifications
+  generate "model Notification recipient_id:integer actor_id:integer read_at:datetime action:string notifiable_id:integer notifiable_type:string"
+  route "resources :notifications, only: [:index]"
+end
+
+def add_administrate
+  generate "administrate:install"
+
+  gsub_file "app/dashboards/announcement_dashboard.rb",
+    /announcement_type: Field::String/,
+    "announcement_type: Field::Select.with_options(collection: Announcement::TYPES)"
+
+  gsub_file "app/dashboards/user_dashboard.rb",
+    /email: Field::String/,
+    "email: Field::String,\n    password: Field::String.with_options(searchable: false)"
+
+  gsub_file "app/dashboards/user_dashboard.rb",
+    /FORM_ATTRIBUTES = \[/,
+    "FORM_ATTRIBUTES = [\n    :password,"
+
+  gsub_file "app/controllers/admin/application_controller.rb",
+    /# TODO Add authentication logic here\./,
+    "redirect_to '/', alert: 'Not authorized.' unless user_signed_in? && current_user.admin?"
+end
+
+def add_app_helpers_to_administrate
+  environment do <<-RUBY
+    # Expose our application's helpers to Administrate
+    config.to_prepare do
+      Administrate::ApplicationController.helper #{@app_name.camelize}::Application.helpers
+    end
+  RUBY
+  end
+end
+
 def add_multiple_authentication
 def add_multiple_authentication
     insert_into_file "config/routes.rb",
     insert_into_file "config/routes.rb",
     ', controllers: { omniauth_callbacks: "users/omniauth_callbacks" }',
     ', controllers: { omniauth_callbacks: "users/omniauth_callbacks" }',
@@ -151,11 +201,28 @@ def add_multiple_authentication
           before: "  # ==> Warden configuration"
           before: "  # ==> Warden configuration"
 end
 end
 
 
+def add_whenever
+  run "wheneverize ."
+end
+
+def add_friendly_id
+  generate "friendly_id"
+
+  insert_into_file(
+    Dir["db/migrate/**/*friendly_id_slugs.rb"].first,
+    "[5.2]",
+    after: "ActiveRecord::Migration"
+  )
+end
 
 
 def stop_spring
 def stop_spring
   run "spring stop"
   run "spring stop"
 end
 end
 
 
+def add_sitemap
+  rails_command "sitemap:install"
+end
+
 # Main setup
 # Main setup
 add_template_repository_to_source_path
 add_template_repository_to_source_path
 
 
@@ -167,9 +234,12 @@ after_bundle do
   add_users
   add_users
   add_bootstrap
   add_bootstrap
   add_sidekiq
   add_sidekiq
-  add_procodile
+  add_foreman
   add_webpack
   add_webpack
+  add_announcements
+  add_notifications
   add_multiple_authentication
   add_multiple_authentication
+  add_friendly_id
 
 
   copy_templates
   copy_templates
 
 
@@ -178,6 +248,14 @@ after_bundle do
   rails_command "db:migrate"
   rails_command "db:migrate"
 
 
   # Migrations must be done before this
   # Migrations must be done before this
+  add_administrate
+
+  add_app_helpers_to_administrate
+
+  add_whenever
+
+  add_sitemap
+
 
 
   git :init
   git :init
   git add: "."
   git add: "."