Skip to content
Snippets Groups Projects
Commit 88daa5a1 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

Publishing branch (#522) and in_production website

parent b57f4055
No related branches found
No related tags found
No related merge requests found
Showing
with 58 additions and 22 deletions
......@@ -90,8 +90,8 @@ GEM
autoprefixer-rails (10.4.7.0)
execjs (~> 2)
aws-eventstream (1.2.0)
aws-partitions (1.637.0)
aws-sdk-core (3.155.0)
aws-partitions (1.644.0)
aws-sdk-core (3.159.0)
aws-eventstream (~> 1, >= 1.0.2)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
......@@ -103,7 +103,7 @@ GEM
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.1)
aws-sigv4 (1.5.2)
aws-eventstream (~> 1, >= 1.0.2)
bcrypt (3.1.18)
bindex (0.8.1)
......@@ -146,7 +146,7 @@ GEM
htmlentities
metainspector (~> 5.12)
nokogiri
delayed_job (4.1.10)
delayed_job (4.1.11)
activesupport (>= 3.0, < 8.0)
delayed_job_active_record (4.1.7)
activerecord (>= 3.0, < 8.0)
......@@ -176,7 +176,7 @@ GEM
faceted_search (3.5.15)
font-awesome-sass
rails (>= 5.2.0)
faraday (2.5.2)
faraday (2.6.0)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
......@@ -193,7 +193,7 @@ GEM
faraday (>= 0.8)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.0)
faraday-net_http (3.0.1)
faraday-retry (2.0.0)
faraday (~> 2.0)
fastimage (2.2.6)
......@@ -286,7 +286,7 @@ GEM
mini_mime (1.1.2)
mini_portile2 (2.8.0)
minitest (5.16.3)
msgpack (1.5.6)
msgpack (1.6.0)
multi_xml (0.6.0)
multipart-post (2.2.3)
mustermann (3.0.0)
......@@ -332,7 +332,7 @@ GEM
rack (2.2.4)
rack-mini-profiler (2.3.4)
rack (>= 1.2.0)
rack-protection (3.0.1)
rack-protection (3.0.2)
rack
rack-test (2.0.2)
rack (>= 1.3)
......@@ -400,7 +400,7 @@ GEM
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
selenium-webdriver (4.4.0)
selenium-webdriver (4.5.0)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2, >= 3.2.5)
rubyzip (>= 1.2.2, < 3.0)
......@@ -420,10 +420,10 @@ GEM
simple_form_password_with_hints (0.0.6)
rails
simple_form
sinatra (3.0.1)
sinatra (3.0.2)
mustermann (~> 3.0)
rack (~> 2.2, >= 2.2.4)
rack-protection (= 3.0.1)
rack-protection (= 3.0.2)
tilt (~> 2.0)
sixarm_ruby_unaccent (1.2.0)
snaky_hash (2.0.1)
......@@ -462,7 +462,7 @@ GEM
activemodel (>= 6.0.0)
bindex (>= 0.4.0)
railties (>= 6.0.0)
webdrivers (5.1.0)
webdrivers (5.2.0)
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0)
......@@ -476,7 +476,7 @@ GEM
websocket-extensions (0.1.5)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.0)
zeitwerk (2.6.1)
zlib (2.1.1)
PLATFORMS
......@@ -551,4 +551,4 @@ RUBY VERSION
ruby 2.7.6p219
BUNDLED WITH
2.3.22
2.3.12
......@@ -81,7 +81,8 @@ class Admin::Communication::WebsitesController < Admin::Communication::Applicati
def website_params
params.require(:communication_website).permit(
:name, :url, :repository, :access_token, :about_type, :about_id, :git_provider, :git_endpoint, :plausible_url, language_ids: []
:name, :url, :repository, :access_token, :about_type, :about_id, :in_production,
:git_provider, :git_endpoint, :git_branch, :plausible_url, language_ids: []
)
end
end
......@@ -5,8 +5,10 @@
# id :uuid not null, primary key
# about_type :string indexed => [about_id]
# access_token :string
# git_branch :string
# git_endpoint :string
# git_provider :integer default("github")
# in_production :boolean default(FALSE)
# name :string
# plausible_url :string
# repository :string
......@@ -52,6 +54,7 @@ class Communication::Website < ApplicationRecord
association_foreign_key: 'language_id'
scope :ordered, -> { order(:name) }
scope :in_production, -> { where(in_production: true) }
scope :for_search_term, -> (term) {
where("
unaccent(communication_websites.name) ILIKE unaccent(:term) OR
......
......@@ -5,8 +5,10 @@
# id :uuid not null, primary key
# about_type :string indexed => [about_id]
# access_token :string
# git_branch :string
# git_endpoint :string
# git_provider :integer default("github")
# in_production :boolean default(FALSE)
# name :string
# plausible_url :string
# repository :string
......
......@@ -5,8 +5,10 @@
# id :uuid not null, primary key
# about_type :string indexed => [about_id]
# access_token :string
# git_branch :string
# git_endpoint :string
# git_provider :integer default("github")
# in_production :boolean default(FALSE)
# name :string
# plausible_url :string
# repository :string
......
class Git::Providers::Abstract
attr_reader :endpoint, :access_token, :repository
attr_reader :endpoint, :branch, :access_token, :repository
def initialize(endpoint, access_token, repository)
def initialize(endpoint, branch, access_token, repository)
@endpoint = endpoint
@branch = branch
@access_token = access_token
@repository = repository
end
......
......@@ -75,7 +75,7 @@ class Git::Providers::Github < Git::Providers::Abstract
end
def default_branch
@default_branch ||= client.repo(repository)[:default_branch]
@default_branch ||= branch || client.repo(repository)[:default_branch]
end
def branch_sha
......
......@@ -38,7 +38,7 @@ class Git::Providers::Gitlab < Git::Providers::Abstract
def push(commit_message)
return if !valid? || batch.empty?
client.create_commit repository,
'main',
branch,
commit_message,
batch
true
......@@ -59,6 +59,10 @@ class Git::Providers::Gitlab < Git::Providers::Abstract
sha
end
def branch
super || 'main'
end
protected
def endpoint
......@@ -76,7 +80,7 @@ class Git::Providers::Gitlab < Git::Providers::Abstract
def find(path)
client.get_file repository,
path,
'main'
branch
rescue
nil
end
......
......@@ -39,6 +39,7 @@ class Git::Repository
def provider
@provider ||= provider_class.new website&.git_endpoint,
website&.git_branch,
website&.access_token,
website&.repository
end
......
......@@ -13,6 +13,7 @@
<%= f.input :url %>
<%= render 'admin/communication/abouts', f: f, i18n_key: 'activerecord.attributes.communication/website.about_' %>
<%= f.association :languages, as: :check_boxes %>
<%= f.input :in_production %>
</div>
</div>
</div>
......@@ -25,11 +26,12 @@
<div class="row">
<div class="col-md-6">
<%= f.input :git_provider, include_blank: false %>
<%= f.input :git_endpoint %>
</div>
<div class="col-md-6">
<%= f.input :git_endpoint %>
<%= f.input :access_token %>
<%= f.input :repository %>
<%= f.input :git_branch %>
</div>
</div>
</div>
......
<% content_for :title, "#{@websites.count} #{Communication::Website.model_name.human(count: @websites.count).downcase}" %>
<p><%= Communication::Website.in_production.count %> en production</p>
<div class="table-responsive">
<table class="<%= table_classes %>">
<thead>
<tr>
<th><%= Communication::Website.human_attribute_name('name') %></th>
<th><%= Communication::Website.human_attribute_name('url') %></th>
<th><%= Communication::Website.human_attribute_name('in_production') %></th>
<th><%= University.model_name.human %></th>
</tr>
</thead>
......@@ -14,6 +17,7 @@
<tr>
<td><%= website.name %></td>
<td><%= link_to website.url, website.url, target: :_blank if website.url.present? %></td>
<td><%= t website.in_production %></td>
<td><%= link_to website.university, [:server, website.university] %></td>
</tr>
<% end %>
......
......@@ -59,8 +59,10 @@ en:
about_Research::Laboratory: Laboratory website
about_type: About
access_token: Access token
git_branch: Git branch
git_endpoint: Git endpoint
git_provider: Git provider
in_production: Production
languages: Languages
name: Name
repository: Repository
......@@ -638,6 +640,7 @@ en:
simple_form:
hints:
communication_website:
git_branch: 'If blank, default branch will be used'
git_endpoint: 'If blank, default will be used (https://github.com or https://gitlab.com/api/v4)'
languages: 'If you select at least one language the website will be considered as possibly multilingual, and therefore all urls will be prefixed with the language (/fr, /en)'
communication_website_category:
......
......@@ -59,8 +59,10 @@ fr:
about_Research::Laboratory: Site de laboratoire
about_type: Type de site
access_token: Access token
git_branch: Branche
git_endpoint: Point d'accès Git
git_provider: Provider Git
in_production: Site en production
languages: Langues
name: Nom
repository: Repository
......@@ -643,6 +645,7 @@ fr:
simple_form:
hints:
communication_website:
git_branch: 'Laisser vide pour la branche par défaut'
git_endpoint: 'Laisser vide pour les valeurs par défaut (https://github.com ou https://gitlab.com/api/v4)'
languages: 'Si vous sélectionnez au moins une langue le site sera considéré comme possiblement multilingue et donc toutes les urls seront préfixées avec la langue (/fr, /en)'
communication_website_category:
......
class AddFieldsToCommunicationWebsite < ActiveRecord::Migration[6.1]
def change
add_column :communication_websites, :git_branch, :string
add_column :communication_websites, :in_production, :boolean, default: false
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2022_10_03_144016) do
ActiveRecord::Schema.define(version: 2022_10_11_070402) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
......@@ -356,6 +356,8 @@ ActiveRecord::Schema.define(version: 2022_10_03_144016) do
t.text "style"
t.date "style_updated_at"
t.string "plausible_url"
t.string "git_branch"
t.boolean "in_production", default: false
t.index ["about_type", "about_id"], name: "index_communication_websites_on_about"
t.index ["university_id"], name: "index_communication_websites_on_university_id"
end
......
......@@ -5,8 +5,10 @@
# id :uuid not null, primary key
# about_type :string indexed => [about_id]
# access_token :string
# git_branch :string
# git_endpoint :string
# git_provider :integer default("github")
# in_production :boolean default(FALSE)
# name :string
# plausible_url :string
# repository :string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment