Add site views
parent
4e23a17bcc
commit
f1e6decb90
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,20 @@
|
|||
// Place all the styles related to the sites controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
|
||||
@import "knacss"
|
||||
|
||||
div::before
|
||||
content: "· "
|
||||
|
||||
.yellow
|
||||
background-color: yellow
|
||||
|
||||
.orange
|
||||
background-color: $orange-500
|
||||
|
||||
.red
|
||||
background-color: $red-500
|
||||
|
||||
.blue
|
||||
background-color: $blue-500
|
|
@ -0,0 +1,9 @@
|
|||
class SitesController < ApplicationController
|
||||
def index
|
||||
@sites = Site.all.distinct.order(:group_id, :url)
|
||||
end
|
||||
|
||||
def show
|
||||
@site = Site.find params[:id]
|
||||
end
|
||||
end
|
|
@ -0,0 +1,2 @@
|
|||
module SitesHelper
|
||||
end
|
|
@ -5,6 +5,9 @@
|
|||
<li>
|
||||
<%= link_to 'Changes', diffs_path %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Sites', sites_path %>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</header>
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
<% last = nil
|
||||
@sites.each do |site|
|
||||
if last != site.group_id
|
||||
last = site.group_id %>
|
||||
<h3><%= site.group&.name || :nogroup %></h3>
|
||||
<% end %>
|
||||
<% changed_at = site.changed_at&.to_date
|
||||
colorclass = case
|
||||
when changed_at.nil?
|
||||
nil
|
||||
when changed_at > 1.day.ago.to_date
|
||||
:red
|
||||
when changed_at > 2.days.ago.to_date
|
||||
:orange
|
||||
when changed_at > 7.days.ago.to_date
|
||||
:yellow
|
||||
end
|
||||
classes = (%i[mls].concat([colorclass])).compact %>
|
||||
<%= content_tag(:div, class: classes) do
|
||||
concat link_to (site.name || site.url), site
|
||||
concat " (last changed: #{l changed_at})" if changed_at
|
||||
end %>
|
||||
<% end %>
|
|
@ -0,0 +1,37 @@
|
|||
<h3><%= link_to (@site.name || @site.url), @site.url %></h3>
|
||||
|
||||
<div class="alert">
|
||||
<strong>group:</strong> <%= @site.group&.name || :none %><br>
|
||||
<strong>template:</strong> <%= @site.template&.name || :none %><br>
|
||||
<strong>last_error:</strong> <%= @site&.last_error %><br>
|
||||
<strong>checked_at:</strong> <%= l @site.checked_at, format: :long if @site.checked_at %><br>
|
||||
<strong>changed_at:</strong> <%= l @site.changed_at, format: :long if @site.changed_at %><br>
|
||||
</div>
|
||||
|
||||
<%= link_to (:back), sites_path %>
|
||||
|
||||
<% @site.diffs.each do |diff| %>
|
||||
<ul class="unstyled mts">
|
||||
<li><%= l diff.created_at, format: :long %>
|
||||
<ul class="unstyled mll mbs">
|
||||
<% diff.content.each do |chunk| %>
|
||||
<li>
|
||||
<%=
|
||||
target = chunk['target']
|
||||
if target
|
||||
target = Target.from_h target
|
||||
content_tag :h4, target
|
||||
end
|
||||
%>
|
||||
<%=
|
||||
chunk = chunk['diff']
|
||||
raw Diffy::Diff.load(chunk).to_s :html
|
||||
%>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
<%= link_to (:back), sites_path %>
|
|
@ -1,3 +1,4 @@
|
|||
Rails.application.routes.draw do
|
||||
resources :diffs, only: %i[index show]
|
||||
resources :sites, only: %i[index show]
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe SitesController, type: :controller do
|
||||
|
||||
end
|
|
@ -11,4 +11,5 @@ require 'rails_helper'
|
|||
# end
|
||||
# end
|
||||
RSpec.describe SitesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue