Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
totem
website
Commits
13b422eb
Unverified
Commit
13b422eb
authored
Jan 13, 2021
by
Maarten de Waard
🤘🏻
Browse files
replace old config with current config
parent
2074bb74
Changes
1
Hide whitespace changes
Inline
Side-by-side
config.rb
View file @
13b422eb
...
...
@@ -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
,
:f
r
,
:f
a
,
]
I18n
.
available_locales
=
[
:en
,
:ar
,
:es
,
:f
a
,
:f
r
,
]
# 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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment