diff --git a/Dockerfile b/Dockerfile index 8ab95fe5c9e3d6a72c44a28e8f06e0e9e9a926dd..1dcd00c66ee6554564533c947f24331ece8f496b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,6 +32,10 @@ COPY . /dtu-course/app RUN rm -rf tmp RUN mkdir tmp +# install bower +RUN npm install -g bower +RUN bower install --allow-root + #RUN mkdir -p ~/.ssh #RUN cp /dtu-data/known_hosts ~/.ssh #RUN ssh-keygen -R github.com diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 93a309505724b38cb0a3cc7ad5be47c176075017..cffd73da2709453de78b8e33c7da5d573bb44aed 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -10,7 +10,6 @@ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // -//= require underscore //= require jquery //= require jquery-ujs //= require MathJax @@ -20,6 +19,8 @@ //= require pagedown-extra/pagedown/Markdown.Editor.js //= require pagedown-extra/Markdown.Extra.js //= require turbolinks -//= require_tree . //= require bootstrap -//= require mathjax \ No newline at end of file +//= require mathjax +//= require_tree . + +//= require render \ No newline at end of file diff --git a/app/assets/javascripts/home.coffee b/app/assets/javascripts/home.coffee index 24f83d18bbd38c24c4f7c3c2fc360cd68e857a2a..43d766d2714690f41890198add41f027977c7137 100644 --- a/app/assets/javascripts/home.coffee +++ b/app/assets/javascripts/home.coffee @@ -1,3 +1,4 @@ # 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/ + diff --git a/app/assets/javascripts/render.js b/app/assets/javascripts/render.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..06e5fde3ed75c56c6f76978e9515e17b09a59249 100644 --- a/app/assets/javascripts/render.js +++ b/app/assets/javascripts/render.js @@ -0,0 +1,71 @@ +function renderPage() { + "use strict"; + + console.log("rendering"); + MathJax.Hub.Config({ + skipStartupTypeset: true, + "HTML-CSS": { + preferredFont: "TeX", + availableFonts: [ + "TeX" + ], + linebreaks: { + automatic: true + }, + EqnChunk: 10, + imageFont: null + }, + root: '/assets/MathJax', + tex2jax: { + inlineMath: [ + ["$", "$"], + ["\\\\\\\\(", "\\\\\\\\)"] + ], + displayMath: [ + ["$$", "$$"], + ["\\\\[", "\\\\]"] + ], + processEscapes: true + }, + TeX: { + noUndefined: { + attributes: { + mathcolor: "red", + mathbackground: "#FFEEEE", + mathsize: "90%" + } + }, + Safe: { + allow: { + URLs: "safe", + classes: "safe", + cssIDs: "safe", + styles: "safe", + fontsize: "all" + } + } + }, + messageStyle: "none" + }); + + + var converter = new Markdown.Converter(); + Markdown.Extra.init(converter, { + table_class: "table table-striped" + }); + mathJax.onPagedownConfigure(converter); + converter.hooks.chain("postConversion", function(x) { + return x + }); + + if (typeof renderCoursePage === "function") { + renderCoursePage(converter); + } + + MathJax.Hub.Queue( + ["Typeset", MathJax.Hub, "content"] + ); +}; + + +$(document).on('ready page:load', renderPage); \ No newline at end of file diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0eb7bdd4a571cb3363ab0eea193cbc3ff8a296f3..cd2cb5fa4a5cdbcb10c9bf3f8d6a17932b4f467c 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -5,9 +5,15 @@ class HomeController < ApplicationController :right_md, :course) def index - @course = "00000" + @course = Rails.configuration.dtu_data[:course] - @left_md = File.read(File.join(DTUAuth::AuthorizationManager.instance.dtu_data_root, @course+'-content', 'Frontpage-left.md')) - @right_md = File.read(File.join(DTUAuth::AuthorizationManager.instance.dtu_data_root, @course+'-content', 'Frontpage-right.md')) + @left_path = File.join(DTUAuth::AuthorizationManager.instance.dtu_data_root, @course+'-content', 'Frontpage-left.md') + @right_path = File.join(DTUAuth::AuthorizationManager.instance.dtu_data_root, @course+'-content', 'Frontpage-right.md') + + Rails.logger.debug(@left_path) + Rails.logger.debug(@right_path) + + @left_md = File.read(@left_path) + @right_md = File.read(@right_path) end end diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 5ac4d0c1c395ad33582c74d8ba8522c220275374..e58ce7a7347b3bbf5c2d8272648d910902aa8445 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -67,60 +67,12 @@ </div> <script> -$(document).on('ready page:load', function() { - "use strict"; -MathJax.Hub.Config({ - skipStartupTypeset: true, - "HTML-CSS": { - preferredFont: "TeX", - availableFonts: [ - "TeX" - ], - linebreaks: { - automatic: true - }, - EqnChunk: 10, - imageFont: null - }, - root: '/assets/MathJax', - tex2jax: { inlineMath: [["$","$"],["\\\\\\\\(","\\\\\\\\)"]], displayMath: [["$$","$$"],["\\\\[","\\\\]"]], processEscapes: true }, - TeX: { - noUndefined: { - attributes: { - mathcolor: "red", - mathbackground: "#FFEEEE", - mathsize: "90%" - } - }, - Safe: { - allow: { - URLs: "safe", - classes: "safe", - cssIDs: "safe", - styles: "safe", - fontsize: "all" - } - } - }, - messageStyle: "none" -}); - - var converter = new Markdown.Converter(); -Markdown.Extra.init(converter, { - table_class: "table table-striped" -}); -mathJax.onPagedownConfigure(converter); -converter.hooks.chain("postConversion", function(x) { - return x -}); -$('.panel-body').html(converter.makeHtml("<%== escape_javascript @left_md %>)")); +function renderCoursePage(converter) { + $('.panel-body').html(converter.makeHtml("<%== escape_javascript @left_md %>)")); $('#content').html(converter.makeHtml("<%== escape_javascript @right_md %>)")); - MathJax.Hub.Queue( - ["Typeset", MathJax.Hub, "content"] - ); - }); +} </script> </div> diff --git a/bower.json b/bower.json index ae15ea5483e962cca95e120f4dec785b5b2dd97d..fc5701be4b65a97cd444e6d055c597fd20124651 100644 --- a/bower.json +++ b/bower.json @@ -23,8 +23,6 @@ "bootstrap": "3.0.3", "jquery": "2.0.3", "jquery-ujs": "1.2.1", - "underscore": "1.5.1", - "requirejs": "~2.1.11", "require-css": "0.1.5", "require-less": "0.1.2", "pagedown-extra": "https://github.com/jmcmanus/pagedown-extra.git#ea782c3d11eb78f57d00aa819527338996a70721", diff --git a/config/application.rb b/config/application.rb index fce906cfc2c2ce28d1485feb7adbe224024175da..1ea0e536c75ab17f1a8c6c6c75caf15af56715c0 100644 --- a/config/application.rb +++ b/config/application.rb @@ -31,5 +31,7 @@ module DTUCourseWebsite # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de + + config.dtu_data = {:course => ENV['COURSE_NAME'], :root_path => ENV['DTU_DATA_ROOT'] || "/dtu-data"} end end diff --git a/dtu-auth/lib/dtu_auth.rb b/dtu-auth/lib/dtu_auth.rb index 8433ac0d4215d94d3ca2c2835157e19b57eaa31b..7736bec753b050cd3c12b0a8a8e6783173a93eee 100644 --- a/dtu-auth/lib/dtu_auth.rb +++ b/dtu-auth/lib/dtu_auth.rb @@ -19,7 +19,7 @@ module DTUAuth def load - self.dtu_data_root = Rails.root.join('../dtu-data/') + self.dtu_data_root = Rails.root.join(Rails.configuration.dtu_data[:root_path]) Rails.logger.debug "Initializing auth module" Rails.logger.info "Using auth data from #{dtu_data_root}"