mumuki-bibliotheca 6.2.2 → 6.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f154a0f7493c9b04b0f3c0e02491271e05760eb36deb8310575a2d8e97fae3b0
|
4
|
+
data.tar.gz: 17cbab22333dcacec4aab3d650a91925f5dbd7024b3ddb7321b7628c6be01740
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e59dc509afcd88bb86d461fdf4265479d50d45a54e4c6114882a1fddbc98bfd79d0c0d1e81008db3617b1dd623f799981b91d230d494d5ef028698348a9eb5aa
|
7
|
+
data.tar.gz: a56954abcc745f68b5e1b5bc6d6c118c4e4a2ea110a19723d7253f8e3060fb31e1e077ae5483a20ba230f700685201f20653bf7203cc8fe88400d2e488be4364
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class Mumuki::Bibliotheca::App < Sinatra::Application
|
2
2
|
helpers do
|
3
|
+
def book
|
4
|
+
Book.find_by_slug! slug.to_s
|
5
|
+
end
|
6
|
+
|
3
7
|
def list_books(books)
|
4
8
|
{ books: books.as_json(only: [:name, :slug, :chapters]) }
|
5
9
|
end
|
@@ -10,14 +14,22 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
|
|
10
14
|
end
|
11
15
|
|
12
16
|
get '/books/writable' do
|
13
|
-
list_books Book.allowed(
|
17
|
+
list_books Book.allowed(permissions)
|
14
18
|
end
|
15
19
|
|
16
20
|
get '/books/:organization/:repository' do
|
17
|
-
|
21
|
+
book.to_resource_h
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/books/:organization/:repository/organizations' do
|
25
|
+
organizations_for book
|
18
26
|
end
|
19
27
|
|
20
28
|
post '/books' do
|
29
|
+
insert_and_notify! :book
|
30
|
+
end
|
31
|
+
|
32
|
+
put'/books' do
|
21
33
|
upsert_and_notify! :book
|
22
34
|
end
|
23
35
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class Mumuki::Bibliotheca::App < Sinatra::Application
|
2
2
|
helpers do
|
3
|
+
def guide
|
4
|
+
Guide.find_by_slug!(slug.to_s)
|
5
|
+
end
|
6
|
+
|
3
7
|
def list_guides(guides)
|
4
8
|
{ guides: guides.map { |it| it.as_json(only: [:name, :slug, :type]).merge(language: it.language.name) } }
|
5
9
|
end
|
@@ -22,14 +26,22 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
|
|
22
26
|
end
|
23
27
|
|
24
28
|
get '/guides/:organization/:repository/markdown' do
|
25
|
-
slice_guide_resource_h_for_api
|
29
|
+
slice_guide_resource_h_for_api guide.to_markdownified_resource_h
|
26
30
|
end
|
27
31
|
|
28
32
|
get '/guides/:organization/:repository' do
|
29
|
-
slice_guide_resource_h_for_api
|
33
|
+
slice_guide_resource_h_for_api guide.to_resource_h
|
34
|
+
end
|
35
|
+
|
36
|
+
get '/guides/:organization/:repository/organizations' do
|
37
|
+
organizations_for guide
|
30
38
|
end
|
31
39
|
|
32
40
|
post '/guides' do
|
41
|
+
insert_and_notify! :guide
|
42
|
+
end
|
43
|
+
|
44
|
+
put '/guides' do
|
33
45
|
upsert_and_notify! :guide
|
34
46
|
end
|
35
47
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
class Mumuki::Bibliotheca::App < Sinatra::Application
|
2
2
|
helpers do
|
3
|
+
def topic
|
4
|
+
Topic.find_by_slug!(slug.to_s)
|
5
|
+
end
|
6
|
+
|
3
7
|
def list_topics(topics)
|
4
8
|
{ topics: topics.as_json(only: [:name, :slug]) }
|
5
9
|
end
|
@@ -10,14 +14,22 @@ class Mumuki::Bibliotheca::App < Sinatra::Application
|
|
10
14
|
end
|
11
15
|
|
12
16
|
get '/topics/writable' do
|
13
|
-
list_topics Topic.allowed(
|
17
|
+
list_topics Topic.allowed(permissions)
|
14
18
|
end
|
15
19
|
|
16
20
|
get '/topics/:organization/:repository' do
|
17
|
-
|
21
|
+
topic.to_resource_h
|
22
|
+
end
|
23
|
+
|
24
|
+
get '/topics/:organization/:repository/organizations' do
|
25
|
+
organizations_for topic
|
18
26
|
end
|
19
27
|
|
20
28
|
post '/topics' do
|
29
|
+
insert_and_notify! :topic
|
30
|
+
end
|
31
|
+
|
32
|
+
put '/topics' do
|
21
33
|
upsert_and_notify! :topic
|
22
34
|
end
|
23
35
|
|
@@ -92,6 +92,10 @@ HTML
|
|
92
92
|
halt 404
|
93
93
|
end
|
94
94
|
|
95
|
+
error Mumukit::Sync::SyncError do
|
96
|
+
halt 400
|
97
|
+
end
|
98
|
+
|
95
99
|
options '*' do
|
96
100
|
response.headers['Allow'] = settings.allow_methods.map { |it| it.to_s.upcase }.join(',')
|
97
101
|
response.headers['Access-Control-Allow-Headers'] = 'X-Mumuki-Auth-Token, X-Requested-With, X-HTTP-Method-Override, Content-Type, Cache-Control, Accept, Authorization'
|
@@ -131,6 +135,11 @@ HTML
|
|
131
135
|
Mumuki::Bibliotheca.api_syncer(json_body)
|
132
136
|
end
|
133
137
|
|
138
|
+
def insert_and_notify!(content_kind)
|
139
|
+
raise Mumukit::Auth::InvalidSlugFormatError, "#{content_kind.as_module_name} with slug #{slug} already exists!" if content_kind.as_module.find_by_slug(slug.to_s)
|
140
|
+
upsert_and_notify!(content_kind)
|
141
|
+
end
|
142
|
+
|
134
143
|
def upsert_and_notify!(content_kind)
|
135
144
|
resource_h = upsert! content_kind
|
136
145
|
|
@@ -156,6 +165,17 @@ HTML
|
|
156
165
|
collection_class.find_by_slug!(slug.to_s).destroy!
|
157
166
|
{}
|
158
167
|
end
|
168
|
+
|
169
|
+
def permissions
|
170
|
+
current_user.permissions
|
171
|
+
end
|
172
|
+
|
173
|
+
def organizations_for(item)
|
174
|
+
Organization
|
175
|
+
.in_path(item)
|
176
|
+
.accessible_as(current_user, :student)
|
177
|
+
.map { |it| it.as_json(only: [:name]) }
|
178
|
+
end
|
159
179
|
end
|
160
180
|
|
161
181
|
post '/markdown' do
|
@@ -173,7 +193,7 @@ HTML
|
|
173
193
|
get '/permissions' do
|
174
194
|
authenticate!
|
175
195
|
|
176
|
-
{permissions:
|
196
|
+
{permissions: permissions}
|
177
197
|
end
|
178
198
|
end
|
179
199
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumuki-bibliotheca
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 6.
|
75
|
+
version: 6.4.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 6.
|
82
|
+
version: 6.4.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: mumukit-login
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0.
|
117
|
+
version: '0.4'
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0.
|
124
|
+
version: '0.4'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rack
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -176,7 +176,7 @@ files:
|
|
176
176
|
- lib/tasks/guides.rake
|
177
177
|
homepage: https://mumuki.org
|
178
178
|
licenses:
|
179
|
-
-
|
179
|
+
- AGPL-3.0
|
180
180
|
metadata: {}
|
181
181
|
post_install_message:
|
182
182
|
rdoc_options: []
|
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
193
|
- !ruby/object:Gem::Version
|
194
194
|
version: '0'
|
195
195
|
requirements: []
|
196
|
-
rubygems_version: 3.0.
|
196
|
+
rubygems_version: 3.0.2
|
197
197
|
signing_key:
|
198
198
|
specification_version: 4
|
199
199
|
summary: API for editing content on mumuki
|