Unverified Commit 13b422eb authored by Maarten de Waard's avatar Maarten de Waard 🤘🏻
Browse files

replace old config with current config

parent 2074bb74
......@@ -45,55 +45,24 @@ activate :sprockets
require 'ruby-cheerio'
helpers do
def edx_api_call(endpoint)
url = config[:edx_api_url] + endpoint
JSON.parse(open(url).read)
end
def get_courses_sorted()
courses = edx_api_call("courses/")
next_page = courses['pagination']['next']
while next_page
more_courses = JSON.parse(open(next_page).read)
courses['results'] = courses['results'] + more_courses['results']
next_page = more_courses['pagination']['next']
end
courses['results'].sort_by! { |course| course['start'] }.reverse!
courses
end
def get_invitation_only_courses
courses = get_courses_sorted()
courses['results'].select! { |course| not course['hidden'] and course['invitation_only'] == true }
courses = data.courses.clone
courses['results'] = data.courses['results'].select { |course| not course['hidden'] and course['invitation_only'] == true }
courses
end
# Courses that do not have "invitation only" set to true.
# You can change this under Settings -> Advanced Settings in Studio.
def get_enrollable_courses
courses = get_courses_sorted()
courses['results'].select! { |course| course['invitation_only'] == false }
courses = data.courses.clone
courses['results'] = data.courses['results'].select { |course| course['invitation_only'] == false }
courses
end
def get_course(course_id)
edx_api_call("courses/" + course_id)
end
def course_url(course_id)
config[:edx_url] + "/courses/" + course_id + "/about"
end
def extract_long_description(overview)
if not overview
return nil
end
if overview == ''
return nil
end
overview
end
# Returns the path to a template in the same way that Padrino searches for it.
# This is needed to check if there is a file that has a `.<language>`
# extension, for example `template.en.md` would be loaded if somebody called
......@@ -111,7 +80,6 @@ helpers do
path.empty? ? :"_#{name}" : :"#{path}#{File::SEPARATOR}#{name}"
end
# Override partial to load template.#{locale} if it exists
def partial(template, options={}, &block)
template_path = _get_template_path template
......@@ -171,7 +139,7 @@ set :edx_url, "https://learn.totem-project.org"
set :edx_api_url, config[:edx_url] + "/api/courses/v1/"
# First locale is considered root path
I18n.available_locales = [:en, :ar, :es, :fr, :fa, ]
I18n.available_locales = [:en, :ar, :es, :fa, :fr, ]
# Influences direction of text flow in the html body
# use text_class to add additional classes to text fields on the home page
......@@ -191,16 +159,16 @@ set :locales, {
text_class: "text-justify",
name: "ES",
long_name: "Español"
}, :fr => {
direction: "ltr",
text_class: "text-justify",
name: "FR",
long_name: "Français"
}, :fa => {
direction: "rtl",
text_class: "",
name: 'فارسی',
long_name: 'فارسی'
}, :fr => {
direction: "ltr",
text_class: "text-justify",
name: "FR",
long_name: "Français"
}
}
......@@ -245,5 +213,3 @@ activate :ogp do |ogp|
# Automatically enables og:url tag
ogp.base_url = 'https://totem-project.org'
end
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment