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
|
crash.log
|
||||||
|
|
||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
|
.bundle/
|
||||||
|
vendor/
|
||||||
|
.byebug_history
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -10,6 +10,8 @@ gem 'nanoc'
|
||||||
gem 'pdfkit'
|
gem 'pdfkit'
|
||||||
gem 'sass'
|
gem 'sass'
|
||||||
gem 'nokogiri'
|
gem 'nokogiri'
|
||||||
|
gem 'faraday'
|
||||||
|
gem 'json'
|
||||||
|
|
||||||
group :nanoc do
|
group :nanoc do
|
||||||
gem 'guard-nanoc'
|
gem 'guard-nanoc'
|
||||||
|
|
|
@ -24,6 +24,8 @@ GEM
|
||||||
equatable (0.6.1)
|
equatable (0.6.1)
|
||||||
eventmachine (1.2.7)
|
eventmachine (1.2.7)
|
||||||
execjs (2.7.0)
|
execjs (2.7.0)
|
||||||
|
faraday (1.0.1)
|
||||||
|
multipart-post (>= 1.2, < 3)
|
||||||
ffi (1.13.1)
|
ffi (1.13.1)
|
||||||
formatador (0.2.5)
|
formatador (0.2.5)
|
||||||
guard (2.16.2)
|
guard (2.16.2)
|
||||||
|
@ -50,6 +52,7 @@ GEM
|
||||||
concurrent-ruby (~> 1.0)
|
concurrent-ruby (~> 1.0)
|
||||||
htmlcompressor (0.4.0)
|
htmlcompressor (0.4.0)
|
||||||
http_parser.rb (0.6.0)
|
http_parser.rb (0.6.0)
|
||||||
|
json (2.3.1)
|
||||||
json_schema (0.20.9)
|
json_schema (0.20.9)
|
||||||
kramdown (2.3.0)
|
kramdown (2.3.0)
|
||||||
rexml
|
rexml
|
||||||
|
@ -63,6 +66,7 @@ GEM
|
||||||
mini_racer (0.3.1)
|
mini_racer (0.3.1)
|
||||||
libv8 (~> 8.4.255)
|
libv8 (~> 8.4.255)
|
||||||
multi_json (1.15.0)
|
multi_json (1.15.0)
|
||||||
|
multipart-post (2.1.1)
|
||||||
nanoc (4.11.18)
|
nanoc (4.11.18)
|
||||||
addressable (~> 2.5)
|
addressable (~> 2.5)
|
||||||
colored (~> 1.2)
|
colored (~> 1.2)
|
||||||
|
@ -140,9 +144,11 @@ DEPENDENCIES
|
||||||
adsf
|
adsf
|
||||||
autoprefixer-rails
|
autoprefixer-rails
|
||||||
byebug
|
byebug
|
||||||
|
faraday
|
||||||
guard-livereload
|
guard-livereload
|
||||||
guard-nanoc
|
guard-nanoc
|
||||||
htmlcompressor
|
htmlcompressor
|
||||||
|
json
|
||||||
kramdown
|
kramdown
|
||||||
mini_racer
|
mini_racer
|
||||||
nanoc
|
nanoc
|
||||||
|
|
7
Rules
7
Rules
|
@ -7,7 +7,8 @@ preprocess do
|
||||||
content = ''
|
content = ''
|
||||||
attributes = {
|
attributes = {
|
||||||
naam: thema,
|
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}"
|
identifier = "/themas/#{thema}"
|
||||||
|
|
||||||
|
@ -15,6 +16,9 @@ preprocess do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Don't just render items from external sources
|
||||||
|
ignore '/external/**/*'
|
||||||
|
|
||||||
compile '/{verenigingen,projecten}/*.md' do
|
compile '/{verenigingen,projecten}/*.md' do
|
||||||
filter :kramdown
|
filter :kramdown
|
||||||
layout '/vereniging.*'
|
layout '/vereniging.*'
|
||||||
|
@ -42,6 +46,7 @@ end
|
||||||
compile '/themas/*' do
|
compile '/themas/*' do
|
||||||
layout '/thema.*'
|
layout '/thema.*'
|
||||||
layout '/default.*'
|
layout '/default.*'
|
||||||
|
layout '/base.*'
|
||||||
write ext: 'html'
|
write ext: 'html'
|
||||||
end
|
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">
|
<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>
|
||||||
<div class="details-container details-contact">
|
<div class="details-container details-contact">
|
||||||
<% if item[:deelname_link] %>
|
<% if item[:deelname_link] %>
|
||||||
<a href="<%= item[:deelname_link] %>"><%= item[:deelname_link] %></a>
|
<a href="<%= item[:deelname_link] %>"><%= item[:deelname_link] %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="contact-container">
|
<div class="contact-container">
|
||||||
<p><a href="<%= item[:contact] %>"><%= item[:contact] %></a></p>
|
<p><a href="<%= item[:contact] %>"><%= item[:contact] %></a></p>
|
||||||
<p><a href="<%= item[:website] %>"><%= item[:website] %></a></p>
|
<p><a href="<%= item[:website] %>"><%= item[:website] %></a></p>
|
||||||
</div>
|
</div>
|
||||||
<div class="social-container">
|
<div class="social-container">
|
||||||
<ul>
|
<ul>
|
||||||
<% if item[:social] %>
|
<% if item[:social] %>
|
||||||
<% for social in item[:social] %>
|
<% for social in item[:social] %>
|
||||||
<li class="social-<%= social[:platform] %>">
|
<li class="social-<%= social[:platform] %>">
|
||||||
<a href="<%= social[:link] %>"><%= social[:link] %></a>
|
<a href="<%= social[:link] %>"><%= social[:link] %></a>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="details-container details-photo">
|
<div class="details-container details-photo">
|
||||||
<div class="showcase-container">
|
<div class="showcase-container">
|
||||||
<% if item[:showcase] %>
|
<% if item[:showcase] %>
|
||||||
<% for showcase_img in item[:showcase] %>
|
<% for showcase_img in item[:showcase] %>
|
||||||
<div class="showcase-image">
|
<div class="showcase-image">
|
||||||
<img src="<%= showcase_img[:photo]%>" alt="showcase img"></img>
|
<img src="<%= showcase_img[:photo] %>" alt="showcase img"></img>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="thema-container">
|
<div class="thema-container">
|
||||||
<% if item[:themas] %>
|
<% if item[:themas] %>
|
||||||
<p><span class="thema-title">Thema's:</span>
|
<p><span class="thema-title">Thema's:</span></p>
|
||||||
<ul>
|
<ul>
|
||||||
<% for thema in item[:themas] %>
|
<% for thema in item[:themas] %>
|
||||||
<li><%= thema %></li>
|
<li>
|
||||||
<% end %>
|
<%= thema %>
|
||||||
</ul>
|
</li>
|
||||||
</p>
|
<% end %>
|
||||||
<% end %>
|
</ul>
|
||||||
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% if item[:verenigingen] %>
|
<% if item[:verenigingen] %>
|
||||||
<div class="details-container details-verenigingen">
|
<div class="details-container details-verenigingen">
|
||||||
<% for vereniging in item[:verenigingen] %>
|
<ul>
|
||||||
|
<% item[:verenigingen].each do |vereniging| %>
|
||||||
|
<li>
|
||||||
<div class="vereninging-container">
|
<div class="vereninging-container">
|
||||||
<p><%= vereniging[:naam] %></p>
|
<p><%= vereniging[:naam] %></p>
|
||||||
<img src="<%= vereniging[:photo] %>" alt="vereniging logo"></img>
|
|
||||||
</div>
|
</div>
|
||||||
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<h1> <%= item[:naam] %> </h1>
|
<h1> Thema: <%= item[:naam] %> </h1>
|
||||||
<div class="details-wrapper">
|
<div class="details-wrapper">
|
||||||
<div class="details-container details-text">
|
<div class="details-container details-text">
|
||||||
<%= yield %>
|
<%= 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
|
# frozen_string_literal: true
|
||||||
|
require 'byebug'
|
||||||
|
|
||||||
# Helpers for data
|
# Helpers for data
|
||||||
module VerenigingenHelper
|
module VerenigingenHelper
|
||||||
|
@ -45,14 +46,6 @@ module VerenigingenHelper
|
||||||
item.identifier.without_ext.split('/').last
|
item.identifier.without_ext.split('/').last
|
||||||
end
|
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)
|
def verenigingen_random(amount)
|
||||||
@items.find_all("**/verenigingen/*").map { |x| {
|
@items.find_all("**/verenigingen/*").map { |x| {
|
||||||
"titel" => x[:titel],
|
"titel" => x[:titel],
|
||||||
|
@ -62,7 +55,23 @@ module VerenigingenHelper
|
||||||
} }.to_a.shuffle[0..amount]
|
} }.to_a.shuffle[0..amount]
|
||||||
end
|
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)
|
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
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,7 +15,8 @@ prune:
|
||||||
data_sources:
|
data_sources:
|
||||||
- type: filesystem
|
- type: filesystem
|
||||||
encoding: utf-8
|
encoding: utf-8
|
||||||
|
- type: dsa_api
|
||||||
|
items_root: /external/dsa_api
|
||||||
checking:
|
checking:
|
||||||
enabled_checks:
|
enabled_checks:
|
||||||
- external_links
|
- external_links
|
||||||
|
|
Loading…
Reference in a new issue