-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.rb
More file actions
45 lines (40 loc) · 1.7 KB
/
Copy pathplugin.rb
File metadata and controls
45 lines (40 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# name: ECHO Navigation
# about: UI Modifications to bring in the ECHO nav bar system to the top of the forums
# version: 3.0.2
# authors: Nate Flood for ECHO Inc
#icons
register_svg_icon "phone" if respond_to?(:register_svg_icon)
# javascript
# The interactive header behaviour (Bootstrap dropdowns/collapse, icon swap,
# search-mode switcher) lives in assets/javascripts/discourse/initializers/echo-nav.js,
# which Discourse auto-loads. Plain register_asset JS is compiled into AMD
# modules that are never imported, so it would never run.
# stylesheet
register_asset "stylesheets/echo-nav.css"
# custom html
register_html_builder('server:header') do |controller|
Rails.cache.fetch("header_#{I18n.locale}", expires_in: 1.day) do
newheader = "<div class='echocommunity_core'>"
begin
newheader += URI.open("https://www.echocommunity.org/#{I18n.locale}/remote/header", :read_timeout => 10).read
newheader += URI.open("https://www.echocommunity.org/#{I18n.locale}/remote/navigation", :read_timeout => 10).read
newheader += URI.open("https://www.echocommunity.org/#{I18n.locale}/remote/language", :read_timeout => 10).read
rescue OpenURI::HTTPError => e
newheader += "An Error Occurred: " + e.message
end
newheader += "</div>"
newheader
end
end
register_html_builder('server:before-body-close') do |controller|
Rails.cache.fetch("footer_#{I18n.locale}", expires_in: 1.day) do
newfooter = "<div class='echocommunity_core'><div class='container-fluid'>"
begin
newfooter += URI.open("https://www.echocommunity.org/#{I18n.locale}/remote/footer", :read_timeout => 10).read
rescue OpenURI::HTTPError => e
newfooter += "An Error Occurred: " + e.message
end
newfooter += "</div></div>"
newfooter
end
end