Browse Source

Amélioration visuelle

webui
Norore 4 years ago
parent
commit
d533684c7d
  1. 50
      app/assets/stylesheets/application.sass
  2. 6
      app/assets/stylesheets/diffy.sass
  3. 16
      app/controllers/diffs_controller.rb
  4. 32
      app/views/diffs/index.html.erb
  5. 49
      app/views/diffs/show.html.erb
  6. 10
      app/views/layouts/application.html.erb
  7. 2
      config/routes.rb
  8. 19
      vendor/assets/stylesheets/knacss/_config/_custom.scss
  9. 2
      vendor/assets/stylesheets/knacss/_config/_variables.scss

50
app/assets/stylesheets/application.sass

@ -8,13 +8,21 @@ $navbar-height: 3.25rem
body
padding-top: $navbar-height
a
color: $link-color-base
text-decoration: underline dashed
&:hover
color: $link-color-base-hover
text-decoration: underline dashed
header
position: fixed
top: 0
width: 100%
//height: $navbar-height
background-color: $color-inverse
background-color: $header-bg-color
color: $background-base
h1
@ -23,7 +31,7 @@ header
padding: 14px 16px
margin: 0
float: left
border-right: 1px solid $background-base
border-right: 1px solid $border-color-base
nav
ul
@ -34,21 +42,51 @@ header
float: left
padding: 14px 16px
list-style-type: none
border-right: 1px solid $background-base
border-right: 1px solid $border-color-base
&:last-child
border-right: none
&:hover
background-color: $color-warning
background-color: darken($header-bg-color-contrast, 25%)
&.active
background-color: $color-success
// background-color: $color-success
background-color: $header-bg-color-contrast
a
color: $background-base
text-decoration: none
&:hover
&:hover, &:active, &:visited
color: $background-base
text-decoration: none
main
h1
color: $h1-text-color
h2
color: $h2-text-color
h3
color: $h3-text-color
h4
color: $h4-text-color
h5
color: $h5-text-color
h6
color: $h6-text-color
div.current
font-weight: 900
background-color: lighten($header-bg-color-contrast, 20%)
border: 1px solid lighten($header-bg-color-contrast, 20%)
&:hover
background-color: inherit
border-color: $link-color-base-hover
div.nodata
font-style: oblique
a
color: $link-color

6
app/assets/stylesheets/diffy.sass

@ -1,6 +1,12 @@
@import "knacss"
.diff
overflow: auto
font-size: 0.75em
padding: 0.4em
border: 1px solid darken($border-color-base, 40%)
border-radius: .8em
box-shadow: 0px 0px 4px $border-color-base
.diff ul
background: #fff

16
app/controllers/diffs_controller.rb

@ -1,10 +1,16 @@
class DiffsController < ApplicationController
def index
limit = params.fetch :limit, 100
offset = params.fetch :offset, 0
last = Diff.order(created_at: :desc).limit(1).first
return redirect_to action: :show, id: last.created_at.to_date if last
end
@diffs = Diff.offset(offset).limit(limit)
.order(:created_at)
.includes(:site)
def show
@dates = Diff.select(:created_at).distinct
@all_dates = []
@dates.each do |d|
@all_dates.push(d.created_at.to_date)
end
@date = Date.parse params[:id]
@diffs = Diff.where created_at: @date..@date+1
end
end

32
app/views/diffs/index.html.erb

@ -1,31 +1,3 @@
<h1>Recent changes</h1>
<h1 id="top">Changes for <%= l last.created_at.to_date %></h1>
<% last_date = nil %>
<% @diffs.each do |diff| %>
<%
site = diff.site
date = diff.created_at.to_date
unless date == last_date
last_date = date %>
<h2><%= l date %></h2>
<% end %>
<h3><%= link_to (site.name || site.url), site.url %></h3>
<ul>
<% diff.content.each do |chunk| %>
<li>
<%=
target = chunk['target']
puts 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>
<% end %>
<div class="alert--info">No changes found!</div>

49
app/views/diffs/show.html.erb

@ -0,0 +1,49 @@
<div class="autogrid txtcenter">
<% (-3..3).each do |n|
date = @date + n %>
<% if @all_dates.include?(date) %>
<%= content_tag :div, class: (:current if @date == date) do %>
<%= link_to l(date), diff_path(date) %>
<% end %>
<% else %>
<%= content_tag :div, class: (:nodata) do %>
<%= link_to l(date), diff_path(date) %>
<%end %>
<% end %>
<% end %>
</div>
<h1 id="top">Changes for <%= l @date %></h1>
<% if @diffs.empty? %>
<div class="alert--info">No changes found!</div>
<% end %>
<% @diffs.each do |diff|
site = diff.site %>
<div class="grid-10">
<div class="col-9">
<h3><%= link_to (site.name || site.url), site.url %></h3>
</div>
<div class="txtright">
<%= link_to "↑ Top ↑", diffs_path(anchor: :top) %>
</div>
</div>
<ul class="unstyled mls">
<% 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>
<% end %>

10
app/views/layouts/application.html.erb

@ -10,10 +10,10 @@
<%= yield :head %>
</head>
<body>
<%= render partial: 'headers' %>
<main role="main" class="pam">
<%= yield %>
</main>
<%= javascript_include_tag 'application' %>
<%= render partial: 'headers' %>
<main role="main" class="pam">
<%= yield %>
</main>
<%= javascript_include_tag 'application' %>
</body>
</html>

2
config/routes.rb

@ -1,3 +1,3 @@
Rails.application.routes.draw do
resources :diffs, only: %i[index]
resources :diffs, only: %i[index show]
end

19
vendor/assets/stylesheets/knacss/_config/_custom.scss

@ -0,0 +1,19 @@
$main-color: #080024; // colorname Black Russian
$main-color-contrast: #b34edc; //colorname Heliotrope
$header-bg-color: $main-color;
$header-bg-color-contrast: $main-color-contrast;
$border-color-base: darken($main-color-contrast, 25%);
$link-color-base: lighten($main-color, 15%);
$link-color-base-hover: darken($main-color-contrast, 25%);
// titres
$h1-text-color: darken($main-color-contrast, 30%);
$h2-text-color: darken($main-color-contrast, 40%);
$h3-text-color: darken($main-color-contrast, 50%);
$h4-text-color: darken($main-color-contrast, 60%);
$h5-text-color: darken($main-color-contrast, 70%);
$h6-text-color: darken($main-color-contrast, 80%);

2
vendor/assets/stylesheets/knacss/_config/_variables.scss

@ -1,5 +1,5 @@
// Config file and project variables
@import "custom";
// ----------------
// Breakpoints zone
// ----------------

Loading…
Cancel
Save