aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhellekin <hellekin@cepheide.org>2020-10-06 04:26:25 +0200
committerhellekin <hellekin@cepheide.org>2020-10-06 04:26:25 +0200
commit56a16be5fb51d8f6a8b04e9e7094aa7c57fb8547 (patch)
tree83280700beda03eaa0786cdd8c94c93a1533f18b
parent09ac92747bfbda80a54e44b22576d29d9dfc63c3 (diff)
downloadincommon-map-56a16be5fb51d8f6a8b04e9e7094aa7c57fb8547.tar.gz
First pass at something visible
This is a first version of the application, to go beyond simple authentication.
-rw-r--r--app/assets/images/login.pngbin0 -> 13568 bytes
-rw-r--r--app/assets/stylesheets/application/_body.scss143
-rw-r--r--app/assets/stylesheets/application/_header.scss28
-rw-r--r--app/assets/stylesheets/application/_user_info.scss64
-rw-r--r--app/assets/stylesheets/resources.scss3
-rw-r--r--app/assets/stylesheets/users.scss3
-rw-r--r--app/controllers/application_controller.rb5
-rw-r--r--app/controllers/resources_controller.rb13
-rw-r--r--app/controllers/users_controller.rb20
-rw-r--r--app/helpers/resources_helper.rb2
-rw-r--r--app/helpers/users_helper.rb2
-rw-r--r--app/views/application/_user_info.html.erb17
-rw-r--r--app/views/layouts/application.html.erb19
-rw-r--r--app/views/resources/delete.html.erb2
-rw-r--r--app/views/resources/edit.html.erb2
-rw-r--r--app/views/resources/index.html.erb2
-rw-r--r--app/views/resources/new.html.erb2
-rw-r--r--app/views/users/index.html.erb4
-rw-r--r--app/views/users/show.html.erb4
-rw-r--r--app/views/welcome/index.html.erb6
-rw-r--r--config/application.rb6
-rw-r--r--config/environments/development.rb6
-rw-r--r--config/routes.rb8
23 files changed, 347 insertions, 14 deletions
diff --git a/app/assets/images/login.png b/app/assets/images/login.png
new file mode 100644
index 0000000..a8cce0d
--- /dev/null
+++ b/app/assets/images/login.png
Binary files differ
diff --git a/app/assets/stylesheets/application/_body.scss b/app/assets/stylesheets/application/_body.scss
new file mode 100644
index 0000000..cadac51
--- /dev/null
+++ b/app/assets/stylesheets/application/_body.scss
@@ -0,0 +1,143 @@
+
+html {
+ color: var(--primary);
+ font-family: var(--font-family);
+ font-size: .938em;
+ line-height: 1.4;
+ background-color: var(--secondary);
+ overflow-y: scroll;
+ direction: ltr;
+ display: block;
+ height: 100%;
+}
+
+body {
+ min-width: 0;
+ min-height: 100%;
+ margin: 0 auto;
+ background-attachment: fixed;
+ background-size: cover;
+ display: block;
+
+ &:before, &:after {
+ content: "";
+ display: table;
+ }
+ &:after {
+ clear: both;
+ }
+
+ > main, > header, > footer {
+ display: block;
+ width: calc(100% - 16px);
+ max-width: 1110px;
+ margin-left: auto;
+ margin-right: auto;
+ padding-left: 8px;
+ padding-right: 8px;
+ }
+}
+
+img {
+ max-width: 100%;
+}
+
+main {
+ position: relative;
+ padding-top: 5.8572em;
+ &:before {
+ content: "";
+ display: table;
+ }
+}
+
+
+:root {
+ --font-family: Helvetica, Arial, sans-serif;
+ --scheme-type: light;
+ --primary: #222;
+ --secondary: #fff;
+ --tertiary: #08c;
+ --quaternary: #e45735;
+ --header-background: #fff;
+ --header-primary: #333;
+ --highlight: #ffff4d;
+ --danger: #e45735;
+ --success: #090;
+ --love: #fa6c8d;
+ --always-black-rgb: 0, 0, 0;
+ --primary-rgb: 34,34,34;
+ --primary-low-rgb: 232.9,232.9,232.9;
+ --secondary-rgb: 255,255,255;
+ --tertiary-rgb: 0,136,204;
+ --primary-very-low: #f8f8f8;
+ --primary-low: #e9e9e9;
+ --primary-low-mid: #bdbdbd;
+ --primary-medium: #919191;
+ --primary-high: #646464;
+ --primary-very-high: #434343;
+ --header-primary-low: #ebebeb;
+ --header-primary-low-mid: #c2c2c2;
+ --header-primary-medium: #999;
+ --header-primary-high: #707070;
+ --header-primary-very-high: #525252;
+ --secondary-low: #4d4d4d;
+ --secondary-medium: gray;
+ --secondary-high: #a6a6a6;
+ --secondary-very-high: #ededed;
+ --tertiary-low: #d1f0ff;
+ --tertiary-medium: #6cf;
+ --tertiary-high: #0aadff;
+ --tertiary-hover: #069;
+ --quaternary-low: #f7cdc2;
+ --highlight-low: #ffffca;
+ --highlight-medium: #ffffa6;
+ --highlight-high: #a6a600;
+ --danger-low: #fbe6e1;
+ --danger-low-mid: rgba(242,171,154,0.7);
+ --danger-medium: #ec8972;
+ --danger-hover: #c63c1b;
+ --success-low: #b8ffb8;
+ --success-medium: #4dff4d;
+ --success-hover: #007a00;
+ --love-low: #fee9ee;
+ --wiki: green;
+ --blend-primary-secondary-5: #f9f9f9;
+ --primary-med-or-secondary-med: #919191;
+ --primary-med-or-secondary-high: #919191;
+ --primary-high-or-secondary-low: #646464;
+ --primary-low-mid-or-secondary-high: #bdbdbd;
+ --primary-low-mid-or-secondary-low: #bdbdbd;
+ --primary-or-primary-low-mid: #222;
+ --highlight-low-or-medium: #ffffca;
+ --tertiary-low-or-tertiary-high: #d1f0ff;
+ --tertiary-med-or-tertiary: #6cf;
+ --secondary-or-primary: #fff;
+ --tertiary-or-white: #08c;
+ --facebook-or-white: #4267b2;
+ --twitter-or-white: #1da1f2;
+ --hljs-comment: #998;
+ --hljs-number: #099;
+ --hljs-string: #d14;
+ --hljs-literal: #458;
+ --hljs-tag: #000080;
+ --hljs-attribute: #008080;
+ --hljs-symbol: #990073;
+ --hljs-bg: #f8f8f8;
+ --google: #fff;
+ --google-hover: #f2f2f2;
+ --instagram: #e1306c;
+ --instagram-hover: #ac194b;
+ --facebook: #4267b2;
+ --facebook-hover: #2d477a;
+ --cas: #70ba61;
+ --twitter: #1da1f2;
+ --twitter-hover: #0c85d0;
+ --github: #100e0f;
+ --github-hover: #463e42;
+ --discord: #7289da;
+ --discord-hover: #4a67cf;
+ --gold: #e7c300;
+ --silver: silver;
+ --bronze: #cd7f32;
+}
diff --git a/app/assets/stylesheets/application/_header.scss b/app/assets/stylesheets/application/_header.scss
new file mode 100644
index 0000000..d0fd5b8
--- /dev/null
+++ b/app/assets/stylesheets/application/_header.scss
@@ -0,0 +1,28 @@
+/* -----------------------------------------------------------------------------
+ HEADER
+----------------------------------------------------------------------------- */
+
+body > header {
+ position: fixed;
+ backface-visibility: hidden;
+ top: 0;
+ left: 0;
+ right: 0;
+ width: 100%;
+ margin: 0 auto;
+ height: 4em;
+ background-color: var(--header-background);
+ box-shadow: 0 2px 4px -1px rgba(0,0,0,0.25);
+ margin-bottom: 15px;
+ display: flex;
+ align-items: center;
+ z-index: 999;
+
+ > h1 {
+ display: flex;
+ font-size: 1em;
+ img {
+ height: 2.667em;
+ }
+ }
+}
diff --git a/app/assets/stylesheets/application/_user_info.scss b/app/assets/stylesheets/application/_user_info.scss
new file mode 100644
index 0000000..be3dad9
--- /dev/null
+++ b/app/assets/stylesheets/application/_user_info.scss
@@ -0,0 +1,64 @@
+/* -----------------------------------------------------------------------------
+User Info
+----------------------------------------------------------------------------- */
+
+#user_info {
+ position: absolute;
+ right: 0;
+
+ nav {
+ top: 0;
+ padding: 0.7rem;
+
+ ul {
+ display: none;
+ position: absolute;
+ right: 0;
+ background-color: var(--header-background);
+ box-shadow: 0 2px 4px -1px rgba(0,0,0,0.25);
+ margin: 0;
+ list-style: none;
+ padding-left: 0;
+ z-index: 1000;
+
+ li {
+ padding: 0.25em 1em;
+ width: 12rem;
+ }
+ }
+
+ &:focus, &:hover {
+ padding-left: 6rem;
+ ul {
+ display: block;
+ margin-top: 0.4em;
+ padding-top: 1em;
+ }
+ }
+
+ > a {
+ display: block;
+ height: 100%;
+ width: 2.2857em;
+ height: 2.2857em;
+ padding: 0.2143em;
+ text-decoration: none;
+ cursor: pointer;
+ border-top: 1px solid transparent;
+ border-left: 1px solid transparent;
+ border-right: 1px solid transparent;
+ transition: all linear 0.15s;
+ outline: none;
+
+ > img {
+ border-radius: 50%;
+ }
+ }
+ }
+
+ &.authenticated {
+
+ }
+ &.anonymous {
+ }
+}
diff --git a/app/assets/stylesheets/resources.scss b/app/assets/stylesheets/resources.scss
new file mode 100644
index 0000000..5f2717f
--- /dev/null
+++ b/app/assets/stylesheets/resources.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the Resources controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: https://sass-lang.com/
diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss
new file mode 100644
index 0000000..aaf17f7
--- /dev/null
+++ b/app/assets/stylesheets/users.scss
@@ -0,0 +1,3 @@
+// Place all the styles related to the users controller here.
+// They will automatically be included in application.css.
+// You can use Sass (SCSS) here: https://sass-lang.com/
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index c34b9f9..4e71ff8 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -7,6 +7,11 @@ class ApplicationController < ActionController::Base
protected
+ def current_agent
+ @current_agent = session[:current_agent] || current_user.presence&.agents&.first&.name || 'IN COMMON'
+ end
+ helper_method :current_agent
+
def current_user
@current_user ||= User.find_by(external_id: session[:current_user]) if session[:current_user].present?
end
diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb
new file mode 100644
index 0000000..1253b5d
--- /dev/null
+++ b/app/controllers/resources_controller.rb
@@ -0,0 +1,13 @@
+class ResourcesController < ApplicationController
+ def index
+ end
+
+ def new
+ end
+
+ def edit
+ end
+
+ def delete
+ end
+end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
new file mode 100644
index 0000000..2cfa2ab
--- /dev/null
+++ b/app/controllers/users_controller.rb
@@ -0,0 +1,20 @@
+class UsersController < ApplicationController
+ # GET /my/users
+ # If you're a leader, you will see a list of Agent members
+ def index
+ begin
+ return 403 unless current_user.agencies.find_by(name: current_agent).leader?
+ rescue Exception => e
+ Rails.logger.info("Exception %s: %s" % [e.class, e.message])
+ flash[:notice] = "Talk to your leader!"
+ redirect_to root_url and return
+ end
+
+ @users = Agent.where(name: current_agent).members
+ end
+
+ # GET /my/account
+ def show
+ @user = current_user
+ end
+end
diff --git a/app/helpers/resources_helper.rb b/app/helpers/resources_helper.rb
new file mode 100644
index 0000000..bbdde9a
--- /dev/null
+++ b/app/helpers/resources_helper.rb
@@ -0,0 +1,2 @@
+module ResourcesHelper
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
new file mode 100644
index 0000000..2310a24
--- /dev/null
+++ b/app/helpers/users_helper.rb
@@ -0,0 +1,2 @@
+module UsersHelper
+end
diff --git a/app/views/application/_user_info.html.erb b/app/views/application/_user_info.html.erb
new file mode 100644
index 0000000..4549684
--- /dev/null
+++ b/app/views/application/_user_info.html.erb
@@ -0,0 +1,17 @@
+<section id="user_info" class="<%= current_user.present? ? 'authenticated' : 'anonymous' %>">
+ <nav>
+ <% if current_user.present? %>
+ <a href="/my/dashboard"><%= image_tag current_user.avatar_url, alt: current_user.username %></a>
+ <ul>
+ <%= tag.li(link_to(new_agent_switch_url, method: :get, remote: true, title: "Changer d'Agent") do
+ "Agent: %s" % current_agent
+ end, id: 'current_agent_name') %>
+ <%= tag.li link_to("Ajouter un point", new_resource_url) %>
+ <%= tag.li link_to("Mon compte", user_url(current_user.id)) %>
+ <%= tag.li link_to("Terminer la session", logout_url) %>
+ </ul>
+ <% else %>
+ <%= link_to image_tag('login.png', alt: 'Se connecter'), '/authenticate' %>
+ <% end %>
+ </nav>
+</section>
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index cfee6e2..4aae3ea 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>IncommonMap</title>
+ <title>Carte IN COMMON</title>
<%= csrf_meta_tags %>
<%= csp_meta_tag %>
@@ -10,6 +10,21 @@
</head>
<body>
- <%= yield %>
+ <header>
+ <h1><%= link_to image_tag("https://talk.incommon.cc/uploads/disc_6_incommon/original/1X/92f926e8210ea7a5412d6e2bdabfa825233e808b.png", alt: "IN COMMON", size: "x4em"), '/' %></h1>
+ <%= render 'application/user_info' %>
+ <%= yield :header %>
+ </header>
+ <main>
+ <article>
+ <%= yield %>
+ </article>
+ </main>
+ <aside>
+ <%= yield :aside %>
+ </aside>
+ <footer>
+ <%= yield :footer %>
+ </footer>
</body>
</html>
diff --git a/app/views/resources/delete.html.erb b/app/views/resources/delete.html.erb
new file mode 100644
index 0000000..837c275
--- /dev/null
+++ b/app/views/resources/delete.html.erb
@@ -0,0 +1,2 @@
+<h1>Resources#delete</h1>
+<p>Find me in app/views/resources/delete.html.erb</p>
diff --git a/app/views/resources/edit.html.erb b/app/views/resources/edit.html.erb
new file mode 100644
index 0000000..61b0939
--- /dev/null
+++ b/app/views/resources/edit.html.erb
@@ -0,0 +1,2 @@
+<h1>Resources#edit</h1>
+<p>Find me in app/views/resources/edit.html.erb</p>
diff --git a/app/views/resources/index.html.erb b/app/views/resources/index.html.erb
new file mode 100644
index 0000000..320849a
--- /dev/null
+++ b/app/views/resources/index.html.erb
@@ -0,0 +1,2 @@
+<h1>Resources#index</h1>
+<p>Find me in app/views/resources/index.html.erb</p>
diff --git a/app/views/resources/new.html.erb b/app/views/resources/new.html.erb
new file mode 100644
index 0000000..c29e88a
--- /dev/null
+++ b/app/views/resources/new.html.erb
@@ -0,0 +1,2 @@
+<h1>Resources#new</h1>
+<p>Find me in app/views/resources/new.html.erb</p>
diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
new file mode 100644
index 0000000..0d53728
--- /dev/null
+++ b/app/views/users/index.html.erb
@@ -0,0 +1,4 @@
+<h1>Users#index</h1>
+<p>Find me in app/views/users/index.html.erb</p>
+
+<p>Show a table with Agent <%= current_agent %> members (<%= pluralize(@users.count, "user") %>), their roles, and ways to change them.</p>
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
new file mode 100644
index 0000000..95ca059
--- /dev/null
+++ b/app/views/users/show.html.erb
@@ -0,0 +1,4 @@
+<h1>Users#show</h1>
+<p>Find me in app/views/users/show.html.erb</p>
+
+<p>Show self information and ways to change stuff.</p>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb
index a1fa276..d1f15c7 100644
--- a/app/views/welcome/index.html.erb
+++ b/app/views/welcome/index.html.erb
@@ -1,8 +1,2 @@
<h1>Bienvenue à l'atelier carto d'IN COMMON</h1>
-<% if current_user.present? %>
- <p>Hi <%= h current_user.name %>, please <%= link_to 'proceed to your dashboard', url_for(action: 'dashboard') %>.</p>
- <p>You may <%= link_to 'sign off', logout_url %>.</p>
-<% else %>
- <p><%= link_to "S'identifier avec Talk.incommon.cc", '/authenticate' %></p>
-<% end %>
diff --git a/config/application.rb b/config/application.rb
index 0ca42d8..1af8ba2 100644
--- a/config/application.rb
+++ b/config/application.rb
@@ -5,10 +5,10 @@ require "rails"
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
-require "active_storage/engine"
+#require "active_storage/engine"
require "action_controller/railtie"
-require "action_mailer/railtie"
-require "action_mailbox/engine"
+#require "action_mailer/railtie"
+#require "action_mailbox/engine"
require "action_text/engine"
require "action_view/railtie"
# require "action_cable/engine"
diff --git a/config/environments/development.rb b/config/environments/development.rb
index 66df51f..3ae395e 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -29,12 +29,12 @@ Rails.application.configure do
end
# Store uploaded files on the local file system (see config/storage.yml for options).
- config.active_storage.service = :local
+ # config.active_storage.service = :local
# Don't care if the mailer can't send.
- config.action_mailer.raise_delivery_errors = false
+ # config.action_mailer.raise_delivery_errors = false
- config.action_mailer.perform_caching = false
+ # config.action_mailer.perform_caching = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
diff --git a/config/routes.rb b/config/routes.rb
index ac3e3f3..d22ee2e 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,7 +3,15 @@ Rails.application.routes.draw do
root to: 'welcome#index'
+ # Resource routes
+ resources :resources
+
+ # User routes
+ get '/my/account', to: 'users#show', as: 'account'
+ get '/my/current_agent', to: 'agent_switch#new', as: 'new_agent_switch'
+ put '/my/current_agent', to: 'agent_switch#update', as: 'update_agent_switch'
get '/my/dashboard', to: 'welcome#dashboard'
+ get 'my/users', to: 'users#index', as: 'users'
# Discourse SSO
get 'authenticate(/:token)', to: 'welcome#authenticate'