Compare commits
3 commits
master
...
dsa-dataso
Author | SHA1 | Date | |
---|---|---|---|
|
c2d3c99022 | ||
|
e675b0d722 | ||
|
81e0912e83 |
11 changed files with 121 additions and 52 deletions
3
.editorconfig
Normal file
3
.editorconfig
Normal file
|
@ -0,0 +1,3 @@
|
|||
[*.erb]
|
||||
indent_style = space
|
||||
indent_size = 2
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -10,3 +10,7 @@ tmp/nanoc/
|
|||
crash.log
|
||||
|
||||
.idea/
|
||||
|
||||
.bundle/
|
||||
vendor/
|
||||
.byebug_history
|
||||
|
|
2
Gemfile
2
Gemfile
|
@ -10,6 +10,8 @@ gem 'nanoc'
|
|||
gem 'pdfkit'
|
||||
gem 'sass'
|
||||
gem 'nokogiri'
|
||||
gem 'faraday'
|
||||
gem 'json'
|
||||
|
||||
group :nanoc do
|
||||
gem 'guard-nanoc'
|
||||
|
|
|
@ -24,6 +24,8 @@ GEM
|
|||
equatable (0.6.1)
|
||||
eventmachine (1.2.7)
|
||||
execjs (2.7.0)
|
||||
faraday (1.0.1)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.13.1)
|
||||
formatador (0.2.5)
|
||||
guard (2.16.2)
|
||||
|
@ -50,6 +52,7 @@ GEM
|
|||
concurrent-ruby (~> 1.0)
|
||||
htmlcompressor (0.4.0)
|
||||
http_parser.rb (0.6.0)
|
||||
json (2.3.1)
|
||||
json_schema (0.20.9)
|
||||
kramdown (2.3.0)
|
||||
rexml
|
||||
|
@ -63,6 +66,7 @@ GEM
|
|||
mini_racer (0.3.1)
|
||||
libv8 (~> 8.4.255)
|
||||
multi_json (1.15.0)
|
||||
multipart-post (2.1.1)
|
||||
nanoc (4.11.18)
|
||||
addressable (~> 2.5)
|
||||
colored (~> 1.2)
|
||||
|
@ -140,9 +144,11 @@ DEPENDENCIES
|
|||
adsf
|
||||
autoprefixer-rails
|
||||
byebug
|
||||
faraday
|
||||
guard-livereload
|
||||
guard-nanoc
|
||||
htmlcompressor
|
||||
json
|
||||
kramdown
|
||||
mini_racer
|
||||
nanoc
|
||||
|
|
7
Rules
7
Rules
|
@ -7,7 +7,8 @@ preprocess do
|
|||
content = ''
|
||||
attributes = {
|
||||
naam: thema,
|
||||
verenigingen: @items.filter{|i| i[:themas] and i[:themas].include?(thema)}.flatten.uniq.compact
|
||||
verenigingen: @items.filter { |i| i[:themas] and i[:themas].include?(thema) }.flatten.uniq.compact,
|
||||
image: '/assets/placeholder.png'
|
||||
}
|
||||
identifier = "/themas/#{thema}"
|
||||
|
||||
|
@ -15,6 +16,9 @@ preprocess do
|
|||
end
|
||||
end
|
||||
|
||||
# Don't just render items from external sources
|
||||
ignore '/external/**/*'
|
||||
|
||||
compile '/{verenigingen,projecten}/*.md' do
|
||||
filter :kramdown
|
||||
layout '/vereniging.*'
|
||||
|
@ -42,6 +46,7 @@ end
|
|||
compile '/themas/*' do
|
||||
layout '/thema.*'
|
||||
layout '/default.*'
|
||||
layout '/base.*'
|
||||
write ext: 'html'
|
||||
end
|
||||
|
||||
|
|
BIN
content/assets/placeholder.png
Normal file
BIN
content/assets/placeholder.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
|
@ -1,54 +1,58 @@
|
|||
<div class="details-container details-logo">
|
||||
<img src="https://dsa.ugent.be/api/verenigingen/<%= abbreviation(item) %>/logo?size=huge" alt="<%= item[:naam] %>">
|
||||
<%= image_tag item %>
|
||||
</div>
|
||||
<div class="details-container details-contact">
|
||||
<% if item[:deelname_link] %>
|
||||
<a href="<%= item[:deelname_link] %>"><%= item[:deelname_link] %></a>
|
||||
<% end %>
|
||||
<div class="contact-container">
|
||||
<p><a href="<%= item[:contact] %>"><%= item[:contact] %></a></p>
|
||||
<p><a href="<%= item[:website] %>"><%= item[:website] %></a></p>
|
||||
</div>
|
||||
<div class="social-container">
|
||||
<ul>
|
||||
<% if item[:social] %>
|
||||
<% for social in item[:social] %>
|
||||
<li class="social-<%= social[:platform] %>">
|
||||
<a href="<%= social[:link] %>"><%= social[:link] %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% if item[:deelname_link] %>
|
||||
<a href="<%= item[:deelname_link] %>"><%= item[:deelname_link] %></a>
|
||||
<% end %>
|
||||
<div class="contact-container">
|
||||
<p><a href="<%= item[:contact] %>"><%= item[:contact] %></a></p>
|
||||
<p><a href="<%= item[:website] %>"><%= item[:website] %></a></p>
|
||||
</div>
|
||||
<div class="social-container">
|
||||
<ul>
|
||||
<% if item[:social] %>
|
||||
<% for social in item[:social] %>
|
||||
<li class="social-<%= social[:platform] %>">
|
||||
<a href="<%= social[:link] %>"><%= social[:link] %></a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="details-container details-photo">
|
||||
<div class="showcase-container">
|
||||
<div class="showcase-container">
|
||||
<% if item[:showcase] %>
|
||||
<% for showcase_img in item[:showcase] %>
|
||||
<div class="showcase-image">
|
||||
<img src="<%= showcase_img[:photo]%>" alt="showcase img"></img>
|
||||
</div>
|
||||
<% end %>
|
||||
<% for showcase_img in item[:showcase] %>
|
||||
<div class="showcase-image">
|
||||
<img src="<%= showcase_img[:photo] %>" alt="showcase img"></img>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="thema-container">
|
||||
<% if item[:themas] %>
|
||||
<p><span class="thema-title">Thema's:</span>
|
||||
<ul>
|
||||
<% for thema in item[:themas] %>
|
||||
<li><%= thema %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</p>
|
||||
<% end %>
|
||||
<% if item[:themas] %>
|
||||
<p><span class="thema-title">Thema's:</span></p>
|
||||
<ul>
|
||||
<% for thema in item[:themas] %>
|
||||
<li>
|
||||
<%= thema %>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% if item[:verenigingen] %>
|
||||
</div>
|
||||
<% if item[:verenigingen] %>
|
||||
<div class="details-container details-verenigingen">
|
||||
<% for vereniging in item[:verenigingen] %>
|
||||
<ul>
|
||||
<% item[:verenigingen].each do |vereniging| %>
|
||||
<li>
|
||||
<div class="vereninging-container">
|
||||
<p><%= vereniging[:naam] %></p>
|
||||
<img src="<%= vereniging[:photo] %>" alt="vereniging logo"></img>
|
||||
<p><%= vereniging[:naam] %></p>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1> <%= item[:naam] %> </h1>
|
||||
<h1> Thema: <%= item[:naam] %> </h1>
|
||||
<div class="details-wrapper">
|
||||
<div class="details-container details-text">
|
||||
<%= yield %>
|
||||
|
|
35
lib/data_sources/dsa_api.rb
Normal file
35
lib/data_sources/dsa_api.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
require 'faraday'
|
||||
require 'json'
|
||||
require 'byebug'
|
||||
|
||||
class DSADataSource < ::Nanoc::DataSource
|
||||
identifier :dsa_api
|
||||
|
||||
def items
|
||||
verenigingen = JSON.parse Faraday.get('https://dsa.ugent.be/api/verenigingen').body
|
||||
puts
|
||||
verenigingen["associations"].map do |vereniging|
|
||||
# byebug
|
||||
puts "Loading #{vereniging["abbreviation"]} from dsa api"
|
||||
new_item(
|
||||
'',
|
||||
vereniging,
|
||||
"/verenigingen/#{vereniging["abbreviation"]}"
|
||||
)
|
||||
# new_item(
|
||||
# Faraday.get(vereniging["logo"]).body,
|
||||
# vereniging,
|
||||
# "/images/#{vereniging["abbreviation"]}"
|
||||
# )
|
||||
end
|
||||
# verenigingen["associations"].map do |vereniging|
|
||||
# # byebug
|
||||
# puts "Loading #{vereniging["abbreviation"]} from dsa api"
|
||||
# new_item(
|
||||
# Faraday.get(vereniging["logo"]).body,
|
||||
# vereniging,
|
||||
# "/images/#{vereniging["abbreviation"]}.jpg"
|
||||
# )
|
||||
# end
|
||||
end
|
||||
end
|
|
@ -1,4 +1,5 @@
|
|||
# frozen_string_literal: true
|
||||
require 'byebug'
|
||||
|
||||
# Helpers for data
|
||||
module VerenigingenHelper
|
||||
|
@ -45,14 +46,6 @@ module VerenigingenHelper
|
|||
item.identifier.without_ext.split('/').last
|
||||
end
|
||||
|
||||
def image_url(item)
|
||||
if item[:image].nil?
|
||||
"https://dsa.ugent.be/api/verenigingen/#{ abbreviation item }/logo?size=medium"
|
||||
else
|
||||
item[:image]
|
||||
end
|
||||
end
|
||||
|
||||
def verenigingen_random(amount)
|
||||
@items.find_all("**/verenigingen/*").map { |x| {
|
||||
"titel" => x[:titel],
|
||||
|
@ -62,7 +55,23 @@ module VerenigingenHelper
|
|||
} }.to_a.shuffle[0..amount]
|
||||
end
|
||||
|
||||
def image_url(item)
|
||||
if item[:image].nil?
|
||||
"https://dsa.ugent.be/api/verenigingen/#{ abbreviation item }/logo?size=medium"
|
||||
else
|
||||
item[:image]
|
||||
end
|
||||
end
|
||||
|
||||
def image_tag(item)
|
||||
"<img src='#{ image_url item }' alt='#{ item[:naam] } logo' />"
|
||||
"<img src='#{ image_url item }' alt='#{ item[:naam] } logo' style='width:15vw;' />"
|
||||
end
|
||||
|
||||
def sorted_dsa_verenigingen
|
||||
# byebug
|
||||
@items.find_all('/external/dsa_api/verenigingen/*')
|
||||
# verenigingen.sort_by do |e|
|
||||
# [ e[:abbreviation] ]
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,8 @@ prune:
|
|||
data_sources:
|
||||
- type: filesystem
|
||||
encoding: utf-8
|
||||
|
||||
- type: dsa_api
|
||||
items_root: /external/dsa_api
|
||||
checking:
|
||||
enabled_checks:
|
||||
- external_links
|
||||
|
|
Loading…
Reference in a new issue