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

Theme management

parent b6167de5
No related branches found
No related tags found
No related merge requests found
...@@ -3,24 +3,13 @@ class Server::WebsitesController < Server::ApplicationController ...@@ -3,24 +3,13 @@ class Server::WebsitesController < Server::ApplicationController
def index def index
@websites = Communication::Website.all.ordered @websites = Communication::Website.all.ordered
breadcrumb breadcrumb
add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path
end end
def edit def refresh
@website = Communication::Website.find params[:id]
breadcrumb
add_breadcrumb @website
end
def update
@website = Communication::Website.find params[:id] @website = Communication::Website.find params[:id]
@website.update_column :theme_version, params[:communication_website][:theme_version] @website.get_current_theme_version!
redirect_to server_websites_path redirect_to server_websites_path
end end
protected
def breadcrumb
super
add_breadcrumb Communication::Website.model_name.human(count: 2), server_websites_path
end
end end
\ No newline at end of file
...@@ -47,6 +47,7 @@ class Communication::Website < ApplicationRecord ...@@ -47,6 +47,7 @@ class Communication::Website < ApplicationRecord
include WithProgramCategories include WithProgramCategories
include WithSpecialPages include WithSpecialPages
include WithStyle include WithStyle
include WithTheme
enum git_provider: { enum git_provider: {
github: 0, github: 0,
......
module Communication::Website::WithStyle module Communication::Website::WithStyle
extend ActiveSupport::Concern extend ActiveSupport::Concern
def preview_style def preview_style
load_style if style_outdated? load_style if style_outdated?
......
module Communication::Website::WithTheme
extend ActiveSupport::Concern
def get_current_theme_version!
self.update_column :theme_version, current_theme_version
end
def theme_version_url
return if url.blank?
"#{url}/osuny-theme-version"
end
protected
def current_theme_version
URI(theme_version_url).read
rescue
'NA'
end
end
\ No newline at end of file
<%= simple_form_for @website, url: server_website_path(@website) do |f| %>
<%= f.input :theme_version %>
<% content_for :action_bar_right do %>
<%= submit f %>
<% end %>
<% end %>
\ No newline at end of file
...@@ -11,20 +11,30 @@ ...@@ -11,20 +11,30 @@
<th><%= Communication::Website.human_attribute_name('in_production') %></th> <th><%= Communication::Website.human_attribute_name('in_production') %></th>
<th><%= Communication::Website.human_attribute_name('theme_version') %></th> <th><%= Communication::Website.human_attribute_name('theme_version') %></th>
<th><%= University.model_name.human %></th> <th><%= University.model_name.human %></th>
<th></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @websites.each do |website| %> <% @websites.each do |website| %>
<tr> <tr>
<td><%= link_to website.name, edit_server_website_path(website) %></td> <td>
<%= link_to website.name, edit_server_website_path(website) %>
</td>
<td> <td>
<%= link_to website.url, website.url, target: :_blank if website.url.present? %> <%= link_to website.url, website.url, target: :_blank if website.url.present? %>
</td> </td>
<td><%= t website.in_production %></td>
<td> <td>
<%= link_to website.theme_version, "#{website.url}/osuny-theme-version", target: :_blank if website.url.present? %> <%= t website.in_production %>
</td>
<td>
<%= link_to website.theme_version, website.theme_version_url, target: :_blank if website.theme_version_url.present? %>
</td>
<td>
<%= link_to website.university, [:server, website.university] %>
</td>
<td>
<%= link_to "Sync version", refresh_server_website_path(website), method: :post, class: button_classes %>
</td> </td>
<td><%= link_to website.university, [:server, website.university] %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
......
namespace :server do namespace :server do
resources :universities, :languages, :websites resources :universities
resources :languages
resources :websites do
member do
post :refresh
end
end
get 'blocks' => 'blocks#index', as: :blocks get 'blocks' => 'blocks#index', as: :blocks
get 'blocks/:id' => 'blocks#show', as: :block get 'blocks/:id' => 'blocks#show', as: :block
post 'blocks/:id' => 'blocks#resave', as: :resave_block post 'blocks/:id' => 'blocks#resave', as: :resave_block
......
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