aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/agents.scss9
-rw-r--r--app/assets/stylesheets/application/_body.scss5
-rw-r--r--app/assets/stylesheets/application/_debug.scss6
-rw-r--r--app/assets/stylesheets/application/_flash.scss6
-rw-r--r--app/assets/stylesheets/application/_header.scss6
-rw-r--r--app/assets/stylesheets/application/_map.scss6
-rw-r--r--app/assets/stylesheets/application/_user_info.scss6
-rw-r--r--app/assets/stylesheets/categories.scss9
-rw-r--r--app/assets/stylesheets/resources.scss6
-rw-r--r--app/assets/stylesheets/taxonomies.scss82
-rw-r--r--app/assets/stylesheets/users.scss6
-rw-r--r--app/assets/stylesheets/welcome.scss6
-rw-r--r--app/controllers/agents_controller.rb91
-rw-r--r--app/controllers/application_controller.rb6
-rw-r--r--app/controllers/categories_controller.rb23
-rw-r--r--app/controllers/my/agent_controller.rb4
-rw-r--r--app/controllers/resources_controller.rb4
-rw-r--r--app/controllers/users_controller.rb4
-rw-r--r--app/controllers/welcome_controller.rb4
-rw-r--r--app/helpers/agents_helper.rb4
-rw-r--r--app/helpers/application_helper.rb47
-rw-r--r--app/helpers/categories_helper.rb6
-rw-r--r--app/helpers/resources_helper.rb4
-rw-r--r--app/helpers/taxonomies_helper.rb23
-rw-r--r--app/helpers/users_helper.rb4
-rw-r--r--app/helpers/welcome_helper.rb4
-rw-r--r--app/jobs/agency_watcher_job.rb4
-rw-r--r--app/jobs/application_job.rb4
-rw-r--r--app/lib/incommon.rb6
-rw-r--r--app/lib/sso.rb4
-rw-r--r--app/lib/sso/from_discourse.rb4
-rw-r--r--app/mailers/application_mailer.rb4
-rw-r--r--app/models/agency.rb4
-rw-r--r--app/models/agent.rb4
-rw-r--r--app/models/application_record.rb4
-rw-r--r--app/models/category.rb4
-rw-r--r--app/models/classification.rb4
-rw-r--r--app/models/resource.rb4
-rw-r--r--app/models/schemas/resource_feature_properties.json4
-rw-r--r--app/models/section.rb4
-rw-r--r--app/models/taxonomy.rb4
-rw-r--r--app/models/user.rb4
-rw-r--r--app/validators/email_validator.rb33
-rw-r--r--app/validators/url_validator.rb33
-rw-r--r--app/views/application/_current_agent_link.html.erb1
-rw-r--r--app/views/application/_current_agent_switch.html.erb4
-rw-r--r--app/views/application/_taxonomy_nav.html.erb6
-rw-r--r--app/views/resources/_resource.html.erb2
48 files changed, 523 insertions, 3 deletions
diff --git a/app/assets/stylesheets/agents.scss b/app/assets/stylesheets/agents.scss
new file mode 100644
index 0000000..ec9285d
--- /dev/null
+++ b/app/assets/stylesheets/agents.scss
@@ -0,0 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+// Place all the styles related to the Agents 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/application/_body.scss b/app/assets/stylesheets/application/_body.scss
index 088f173..06db39a 100644
--- a/app/assets/stylesheets/application/_body.scss
+++ b/app/assets/stylesheets/application/_body.scss
@@ -1,3 +1,8 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
html {
color: var(--primary);
diff --git a/app/assets/stylesheets/application/_debug.scss b/app/assets/stylesheets/application/_debug.scss
index 75b1988..0e3aaa7 100644
--- a/app/assets/stylesheets/application/_debug.scss
+++ b/app/assets/stylesheets/application/_debug.scss
@@ -1,4 +1,10 @@
/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+/*
DEBUG
*/
diff --git a/app/assets/stylesheets/application/_flash.scss b/app/assets/stylesheets/application/_flash.scss
index c373796..f168e68 100644
--- a/app/assets/stylesheets/application/_flash.scss
+++ b/app/assets/stylesheets/application/_flash.scss
@@ -1,4 +1,10 @@
/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+/*
FLASH
*/
diff --git a/app/assets/stylesheets/application/_header.scss b/app/assets/stylesheets/application/_header.scss
index d0fd5b8..3c7d460 100644
--- a/app/assets/stylesheets/application/_header.scss
+++ b/app/assets/stylesheets/application/_header.scss
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
/* -----------------------------------------------------------------------------
HEADER
----------------------------------------------------------------------------- */
diff --git a/app/assets/stylesheets/application/_map.scss b/app/assets/stylesheets/application/_map.scss
index d6f66f7..e474843 100644
--- a/app/assets/stylesheets/application/_map.scss
+++ b/app/assets/stylesheets/application/_map.scss
@@ -1,4 +1,10 @@
/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+/*
MAP
*/
diff --git a/app/assets/stylesheets/application/_user_info.scss b/app/assets/stylesheets/application/_user_info.scss
index cb0d159..765be0a 100644
--- a/app/assets/stylesheets/application/_user_info.scss
+++ b/app/assets/stylesheets/application/_user_info.scss
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
/* -----------------------------------------------------------------------------
User Info
----------------------------------------------------------------------------- */
diff --git a/app/assets/stylesheets/categories.scss b/app/assets/stylesheets/categories.scss
new file mode 100644
index 0000000..6e6299f
--- /dev/null
+++ b/app/assets/stylesheets/categories.scss
@@ -0,0 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+// Place all the styles related to the Categories 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/resources.scss b/app/assets/stylesheets/resources.scss
index 5f2717f..eb7411b 100644
--- a/app/assets/stylesheets/resources.scss
+++ b/app/assets/stylesheets/resources.scss
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-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/taxonomies.scss b/app/assets/stylesheets/taxonomies.scss
new file mode 100644
index 0000000..446fd20
--- /dev/null
+++ b/app/assets/stylesheets/taxonomies.scss
@@ -0,0 +1,82 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
+body>aside {
+ width: auto;
+
+ span[data-target="taxonomy.filter"] {
+ z-index: 990;
+ background: var(--icon-menu-on) top left/32px no-repeat;
+ width: 32px;
+ height: 32px;
+ position: absolute;
+ top: 6.1rem;
+ left: 10px;
+
+ &.off {
+ background-image: var(--icon-menu-off);
+ }
+ &.on {
+ background-image: var(--icon-menu-on);
+ }
+ }
+
+ nav {
+ z-index: 900;
+ position: fixed;
+ top: 5.5rem;
+ bottom: 0;
+ margin: 0;
+ padding: 0;
+ background-color: var(--incommon-blue);
+ display: block;
+ border-top-right-radius: 1rem;
+ width: 20rem;
+ height: calc(100% - 7.5rem);
+ padding-top: 48px;
+ }
+}
+
+/* Dewey Taxonomy */
+#taxonomy-2519915f-d19c-4281-b758-f5ddb889d7fa {
+ ol {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+
+ li {
+ padding: 0.5rem 1rem;
+ }
+
+ ol {
+ display: none;
+ }
+ ol.active {
+ font-weight: bold;
+ text-align: right;
+ li {
+ display: initial;
+ &.active {
+ font-weight: bold;
+ text-align: right;
+ }
+ }
+ }
+ }
+
+ #category-30 { background-color: #BCBCBC; }
+ #category-31 { background-color: #95a5a6; }
+ #category-32 { background-color: #848482; }
+ #category-33 { background-color: #948279; }
+ #category-34 { background-color: #59706a; }
+ #category-35 { background-color: #16a085; }
+ #category-36 { background-color: #27ae60; }
+ #category-37 { background-color: #2980b9; }
+ #category-38 { background-color: #34495e; }
+ #category-39 { background-color: #bd3525; }
+ #category-40 { background-color: #d35400; }
+ #category-42 { background-color: #eead0e; }
+}
diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss
index aaf17f7..38fcd72 100644
--- a/app/assets/stylesheets/users.scss
+++ b/app/assets/stylesheets/users.scss
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-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/assets/stylesheets/welcome.scss b/app/assets/stylesheets/welcome.scss
index d7704ef..aae15d5 100644
--- a/app/assets/stylesheets/welcome.scss
+++ b/app/assets/stylesheets/welcome.scss
@@ -1,3 +1,9 @@
+/*
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc
+ *
+ * SPDX-License-Identifier: LAL-1.3
+ */
+
// Place all the styles related to the welcome 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/agents_controller.rb b/app/controllers/agents_controller.rb
new file mode 100644
index 0000000..105e443
--- /dev/null
+++ b/app/controllers/agents_controller.rb
@@ -0,0 +1,91 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+class AgentsController < ApplicationController
+ before_action :set_agent, only: [:new, :show, :edit, :update, :delete, :destroy]
+
+ # GET /agents
+ def index
+ @agents = Agent.order(:name).page params[:page]
+ end
+
+ # GET /agents/new
+ def new
+ end
+
+ # POST /agents
+ def create
+ flash.now[:alert] = 'Agents are created from actual groups for now...'
+ render :new
+ end
+
+ # GET /agents/:id
+ def show
+ end
+
+ # GET /agents/:id/edit
+ def edit
+ flash.now[:notice] = 'Please ask a maintainer to edit this resource!' unless current_user_maintainer?
+ end
+
+ # PATCH /agents/:id
+ def update
+ # Check list:
+ # 1. Compare records for changes
+ # 2. Validate each change
+ # 3. Moderate queue or save
+
+ return 403 unless current_user_maintainer?
+
+ respond_to do |format|
+ if @agent.update(agent_params)
+ format.html { redirect_to @agent, notice: 'Merci de votre contribution !' }
+ format.json { render :show, status: :ok, location: @agent }
+ else
+ format.html { render :edit }
+ format.json { render json: @agent.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # GET /agents/:id/delete
+ def delete
+ flash.now[:notice] = 'Please ask a maintainer to delete your Agent!' unless current_user_maintainer?
+ end
+
+ # DELETE /agents/:id
+ def destroy
+ return 403 # Yeah, right?
+ # Check list
+ # 1. User belongs to Agent and is :maintainer?
+ if !(current_user_maintainer? && current_user_leader?)
+ msg = 'You must be a maintainer and a leader to delete your Agent!'
+ respond_to do |format|
+ format.html { redirect_to :show, notice: msg }
+ format.json { render json: '{}', status: :forbidden, message: msg }
+ end
+ else
+ @agent.destroy
+ respond_to do |format|
+ format.html { redirect_to :index, notice: 'OK, resource Agent successfully removed.' }
+ format.json { head :no_content }
+ end
+ end
+ end
+
+ private
+
+ def agent_params
+ params
+ .require(:agent)
+ .permit(:uuid,
+ :name,
+ :summary,
+ :description)
+ end
+
+ def set_agent
+ @agent = Agent.find_by(uuid: params[:id]) || Agent.new
+ end
+end
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index 14f50bf..5299f54 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,6 +1,8 @@
-class ApplicationController < ActionController::Base
- protect_from_forgery with: :null_session
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+class ApplicationController < ActionController::Base
require 'sso'
before_action :current_user
diff --git a/app/controllers/categories_controller.rb b/app/controllers/categories_controller.rb
new file mode 100644
index 0000000..40f1ff5
--- /dev/null
+++ b/app/controllers/categories_controller.rb
@@ -0,0 +1,23 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+class CategoriesController < ApplicationController
+ before_action :set_category, only: [:new, :show, :edit, :update, :delete, :destroy]
+
+ def index
+ end
+
+ def show
+ @category = Category.find(params[:id])
+ end
+
+ def edit
+ end
+
+ private
+
+ def set_category
+ @category = Category.find_by(id: params[:id]) || Category.new
+ end
+end
diff --git a/app/controllers/my/agent_controller.rb b/app/controllers/my/agent_controller.rb
index ac761b7..6da2642 100644
--- a/app/controllers/my/agent_controller.rb
+++ b/app/controllers/my/agent_controller.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class My::AgentController < ApplicationController
# PATCH /my/current_agent
def switch
diff --git a/app/controllers/resources_controller.rb b/app/controllers/resources_controller.rb
index 04d4e70..52d89ea 100644
--- a/app/controllers/resources_controller.rb
+++ b/app/controllers/resources_controller.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class ResourcesController < ApplicationController
before_action :set_resource, only: [:new, :show, :edit, :update, :delete, :destroy]
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 2cfa2ab..9a3cf74 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class UsersController < ApplicationController
# GET /my/users
# If you're a leader, you will see a list of Agent members
diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb
index ee76eb6..e7743e8 100644
--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class WelcomeController < ApplicationController
# GET /
def index
diff --git a/app/helpers/agents_helper.rb b/app/helpers/agents_helper.rb
index 7e54438..bbaeeca 100644
--- a/app/helpers/agents_helper.rb
+++ b/app/helpers/agents_helper.rb
@@ -1,2 +1,6 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
module AgentsHelper
end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index aa3a8d7..15d5082 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
module ApplicationHelper
def current_agency
current_user.agencies.where(agent: current_agent).first
@@ -21,4 +25,47 @@ module ApplicationHelper
'map-zoom': map.zoom
})
end
+
+ # Markdown helper
+ # Always use all extensions. Additional parser and render options may be
+ # passed as a second argument.
+ #
+ # @param markdown (String) a string to parse as Markdown source
+ # @param options (String or Array) an optional parser/renderer option
+ # @return String HTML-formatted from Mardkown source
+ def m(markdown, options = nil)
+ tag.div(
+ CommonMarker.render_doc(
+ markdown.to_s,
+ options.to_a + default_commonmarker_options,
+ default_commonmarker_extensions
+ ).to_html.html_safe, class: 'markdown')
+ end
+
+ private
+
+ # CommonMarker extensions
+ # See https://github.com/gjtorikian/commonmarker#extensions
+ def default_commonmarker_extensions
+ [
+ :table,
+ :tasklist,
+ :strikethrough,
+ :autolink,
+ :tagfilter
+ ]
+ end
+
+ # CommonMarker options
+ # See https://github.com/gjtorikian/commonmarker#options
+ def default_commonmarker_options
+ [
+ #:HARDBREAKS, # only seems to work with render_html, but then all others
+ # only work with render_doc
+ :FOOTNOTES,
+ :SMART,
+ :STRIKETHROUGH_DOUBLE_TILDE,
+ :VALIDATE_UTF8
+ ]
+ end
end
diff --git a/app/helpers/categories_helper.rb b/app/helpers/categories_helper.rb
new file mode 100644
index 0000000..f6d7a86
--- /dev/null
+++ b/app/helpers/categories_helper.rb
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+module CategoriesHelper
+end
diff --git a/app/helpers/resources_helper.rb b/app/helpers/resources_helper.rb
index 157a8f5..a949311 100644
--- a/app/helpers/resources_helper.rb
+++ b/app/helpers/resources_helper.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
module ResourcesHelper
# Return a SELECT tag to choose a section in a given taxonomy
def section_select(taxonomy, selected = nil)
diff --git a/app/helpers/taxonomies_helper.rb b/app/helpers/taxonomies_helper.rb
new file mode 100644
index 0000000..a584177
--- /dev/null
+++ b/app/helpers/taxonomies_helper.rb
@@ -0,0 +1,23 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+# coding: utf-8
+# frozen_string_literal: true
+
+module TaxonomiesHelper
+ def taxonomy_filter
+ @taxonomy ||= Taxonomy.first
+ html = []
+ @taxonomy.categories.each do |cat|
+ list = []
+ cat.sections.each do |sec|
+ list << tag.li(h("#{sec.rank}. #{sec.name}"), id: "section-#{sec.id}", data: { action: "taxonomy#section" })
+ end
+ html << tag.li(h("#{cat.rank}. #{cat.name}") << tag.ol(list.join.html_safe),
+ id: "category-#{cat.id}",
+ data: { action: "taxonomy#category" })
+ end
+ raw(tag.nav(tag.ol(html.join.html_safe), id: "taxonomy-#{@taxonomy.uuid}"))
+ end
+end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 2310a24..0adb3be 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,2 +1,6 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
module UsersHelper
end
diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb
index eeead45..8e575f1 100644
--- a/app/helpers/welcome_helper.rb
+++ b/app/helpers/welcome_helper.rb
@@ -1,2 +1,6 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
module WelcomeHelper
end
diff --git a/app/jobs/agency_watcher_job.rb b/app/jobs/agency_watcher_job.rb
index 5d154be..23266e8 100644
--- a/app/jobs/agency_watcher_job.rb
+++ b/app/jobs/agency_watcher_job.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
# frozen_string_literal: true
# = AgencyWatcherJob
diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb
index d394c3d..9f811cb 100644
--- a/app/jobs/application_job.rb
+++ b/app/jobs/application_job.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
diff --git a/app/lib/incommon.rb b/app/lib/incommon.rb
new file mode 100644
index 0000000..091f022
--- /dev/null
+++ b/app/lib/incommon.rb
@@ -0,0 +1,6 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+module INCOMMON
+end
diff --git a/app/lib/sso.rb b/app/lib/sso.rb
index 0939a7c..088f436 100644
--- a/app/lib/sso.rb
+++ b/app/lib/sso.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2018-2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
# frozen_string_literal: true
# Perform Single Sign-On using Discourse
diff --git a/app/lib/sso/from_discourse.rb b/app/lib/sso/from_discourse.rb
index a5df192..94969c9 100644
--- a/app/lib/sso/from_discourse.rb
+++ b/app/lib/sso/from_discourse.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2018-2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
# frozen_string_literal: true
module SSO
diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb
index 286b223..1900454 100644
--- a/app/mailers/application_mailer.rb
+++ b/app/mailers/application_mailer.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class ApplicationMailer < ActionMailer::Base
default from: 'from@example.com'
layout 'mailer'
diff --git a/app/models/agency.rb b/app/models/agency.rb
index 03e6e5a..7ffe489 100644
--- a/app/models/agency.rb
+++ b/app/models/agency.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Agency < ApplicationRecord
include Bitfields
diff --git a/app/models/agent.rb b/app/models/agent.rb
index 6264ba3..28ba579 100644
--- a/app/models/agent.rb
+++ b/app/models/agent.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Agent < ApplicationRecord
has_many :agencies
has_many :members, through: :agencies, source: :user
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 10a4cba..81dc6c5 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class ApplicationRecord < ActiveRecord::Base
self.abstract_class = true
end
diff --git a/app/models/category.rb b/app/models/category.rb
index b8c49f1..6868bf7 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Category < ApplicationRecord
belongs_to :taxonomy
has_many :sections,
diff --git a/app/models/classification.rb b/app/models/classification.rb
index c384aa7..0754054 100644
--- a/app/models/classification.rb
+++ b/app/models/classification.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Classification < ApplicationRecord
belongs_to :resource
belongs_to :section
diff --git a/app/models/resource.rb b/app/models/resource.rb
index 7d87e1a..8df106c 100644
--- a/app/models/resource.rb
+++ b/app/models/resource.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
require_dependency 'phony_rails'
class Resource < ApplicationRecord
diff --git a/app/models/schemas/resource_feature_properties.json b/app/models/schemas/resource_feature_properties.json
index 84cd6ae..888b546 100644
--- a/app/models/schemas/resource_feature_properties.json
+++ b/app/models/schemas/resource_feature_properties.json
@@ -1,3 +1,7 @@
+/**
+ * SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+ * SPDX-License-Identifier: CC-BY-SA-4.0
+**/
// JSON Schema for Resource#feature
{
"$schema": "http://json-schema.org/draft-07/schema#",
diff --git a/app/models/section.rb b/app/models/section.rb
index 7d26882..16213c7 100644
--- a/app/models/section.rb
+++ b/app/models/section.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Section < ApplicationRecord
belongs_to :category
has_one :taxonomy, through: :category
diff --git a/app/models/taxonomy.rb b/app/models/taxonomy.rb
index 0810fc0..34f65f6 100644
--- a/app/models/taxonomy.rb
+++ b/app/models/taxonomy.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class Taxonomy < ApplicationRecord
# Universally Unique Identifier :uuid
include UUIDParameter
diff --git a/app/models/user.rb b/app/models/user.rb
index f7e96a8..9b199ac 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,3 +1,7 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
class User < ApplicationRecord
has_many :agencies
has_many :agents, through: :agencies, source: :agent
diff --git a/app/validators/email_validator.rb b/app/validators/email_validator.rb
new file mode 100644
index 0000000..4191907
--- /dev/null
+++ b/app/validators/email_validator.rb
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+# frozen_string_literal: true
+
+# = Email Validator =
+#
+# In order to be considered valid, value must be:
+#
+# - a valid Email URI
+# - parsable as an URI
+# - have a hostname
+# - have a valid public TLD
+#
+class EmailValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ unless valid_email_address?(value)
+ record.errors[attribute] << (options[:message] || 'is an invalid email address')
+ end
+ end
+
+ private
+
+ def valid_email_address?(value)
+ uri = URI.parse("mailto:#{value}")
+ uri.is_a?(URI::MailTo) &&
+ uri.to == value &&
+ IANA::TLD.valid?(value.split('@', 2).last.split('.').compact.last)
+ rescue URI::InvalidURIError, URI::InvalidComponentError
+ false
+ end
+end
diff --git a/app/validators/url_validator.rb b/app/validators/url_validator.rb
new file mode 100644
index 0000000..5f790b3
--- /dev/null
+++ b/app/validators/url_validator.rb
@@ -0,0 +1,33 @@
+# SPDX-FileCopyrightText: 2020 IN COMMON Collective <collective@incommon.cc>
+#
+# SPDX-License-Identifier: AGPL-3.0-or-later
+
+# frozen_string_literal: true
+
+# = URL Validator =
+#
+# In order to be considered valid, value must be:
+#
+# - parsable as an URI
+# - use the http or https scheme
+# - have a hostname
+# - have a valid public TLD
+#
+class UrlValidator < ActiveModel::EachValidator
+ def validate_each(record, attribute, value)
+ unless valid_web_address?(value)
+ record.errors[attribute] << (options[:message] || 'is an invalid Web URL')
+ end
+ end
+
+ private
+
+ def valid_web_address?(value)
+ uri = URI.parse(value)
+ uri.is_a?(URI::HTTP) &&
+ uri.host.present? &&
+ IANA::TLD.valid?(uri.host.split('.').compact.last)
+ rescue URI::InvalidURIError
+ false
+ end
+end
diff --git a/app/views/application/_current_agent_link.html.erb b/app/views/application/_current_agent_link.html.erb
new file mode 100644
index 0000000..58bf5fb
--- /dev/null
+++ b/app/views/application/_current_agent_link.html.erb
@@ -0,0 +1 @@
+<%= render partial: 'current_agent_switch' %>
diff --git a/app/views/application/_current_agent_switch.html.erb b/app/views/application/_current_agent_switch.html.erb
new file mode 100644
index 0000000..f19f26b
--- /dev/null
+++ b/app/views/application/_current_agent_switch.html.erb
@@ -0,0 +1,4 @@
+<%= form_for current_agent, url: '/my/current_agent', method: :patch do |f| %>
+ <%= f.select(:id, options_for_select(current_user.agents.map { |a| [a.name, a.id] }, selected: current_agent.id), title: "Sélectionner l'agent en cours") %>
+ <%= f.submit(" » ", title: "Activer cet Agent") %>
+<% end %>
diff --git a/app/views/application/_taxonomy_nav.html.erb b/app/views/application/_taxonomy_nav.html.erb
new file mode 100644
index 0000000..2203665
--- /dev/null
+++ b/app/views/application/_taxonomy_nav.html.erb
@@ -0,0 +1,6 @@
+<% out = []
+clazo.each do |c| %>
+ <%= tag.span(taxo.name) %> »
+ <%= link_to(c.section.category.name, c.section.category) %> »
+ <%= link_to(c.section.name, c.section) %> »
+<% end %>
diff --git a/app/views/resources/_resource.html.erb b/app/views/resources/_resource.html.erb
index 652da59..37c0d66 100644
--- a/app/views/resources/_resource.html.erb
+++ b/app/views/resources/_resource.html.erb
@@ -5,7 +5,7 @@
<time datetime="<%= h resource.updated_at %>" class="updated_at">
<p class="identifier"><%= resource_url(resource) %></p>
</header>
- <div><%= h resource.description %></div>
+ <%= m resource.description %>
<hr>
<code><pre><%= h JSON.pretty_generate(resource.feature.as_json) %></pre></code>
<nav>