Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
erp5
Commits
1622517c
Commit
1622517c
authored
Oct 05, 2016
by
Sven Franck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_officejs_afs_directory: switch from local JSON to fetching remotely from Github
parent
e92290e6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
63 deletions
+51
-63
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js
...emplateItem/web_page_module/gadget_erp5_afs_storage_js.js
+48
-60
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml
...js_afs_directory/PathTemplateItem/web_site_module/afs.xml
+3
-3
No files found.
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js
View file @
1622517c
/*
* Copyright 2016, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/*jslint nomen: true*/
/*global jIO, RSVP, DOMParser, Blob */
(
function
(
jIO
,
RSVP
,
JSON
,
UriTemplate
)
{
/*global jIO, RSVP, JSON */
(
function
(
jIO
,
RSVP
,
JSON
)
{
"
use strict
"
;
var
DOCUMENT_URL
=
"
{document_id}
"
,
document_url_template
=
UriTemplate
.
parse
(
DOCUMENT_URL
);
function
ajax
(
storage
,
options
)
{
if
(
options
===
undefined
)
{
options
=
{};
}
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
jIO
.
util
.
ajax
(
options
);
});
}
function
PublisherStorage
(
spec
)
{
// NOTE: requires Website Layout Configuration CSP modification
// => connect-src 'self' https://raw.githubusercontent.com https://api.github.com data:;
//https://api.github.com/repos/Nexedi/awesome-free-software
//https://api.github.com/repos/Nexedi/awesome-free-software/contents/?ref=master
//https://api.github.com/repos/Nexedi/awesome-free-software/contents/alfresco.json
//https://raw.githubusercontent.com/Nexedi/awesome-free-software/master/alfresco.json
this
.
_href
=
spec
.
href
||
'
https://api.github.com/repos/
'
;
this
.
_user
=
spec
.
user
||
'
Nexedi
'
;
this
.
_repo
=
spec
.
repo
||
'
awesome-free-software
'
;
}
PublisherStorage
.
prototype
.
get
=
function
(
id
)
{
var
context
=
this
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
ajax
(
context
,
{
type
:
"
GET
"
,
url
:
document_url_template
.
expand
({
document_id
:
id
}),
dataType
:
"
text
"
,
});
return
jIO
.
util
.
ajax
({
type
:
"
GET
"
,
url
:
id
,
dataType
:
"
text
"
});
})
.
push
(
function
(
response
)
{
return
JSON
.
parse
(
response
.
target
.
response
||
response
.
target
.
responseText
);
},
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
.
push
(
function
(
response
)
{
return
JSON
.
parse
(
response
.
target
.
response
||
response
.
target
.
responseText
);
},
function
(
error
)
{
if
((
error
.
target
!==
undefined
)
&&
(
error
.
target
.
status
===
404
))
{
throw
new
jIO
.
util
.
jIOError
(
"
Cannot find document
"
,
404
);
}
throw
error
;
}
throw
error
;
});
);
};
PublisherStorage
.
prototype
.
hasCapacity
=
function
(
name
)
{
...
...
@@ -54,32 +42,32 @@
};
PublisherStorage
.
prototype
.
buildQuery
=
function
(
options
)
{
var
context
=
this
,
rows
=
[];
var
url
=
this
.
_href
+
this
.
_user
+
'
/
'
+
this
.
_repo
+
'
/contents/?ref=master
'
;
return
new
RSVP
.
Queue
()
.
push
(
function
()
{
return
ajax
(
context
,
{
type
:
"
GET
"
,
url
:
document_url_template
.
expand
({
document_id
:
'
publisher_list.txt
'
})
});
})
.
push
(
function
(
response
)
{
var
response_list
=
(
response
.
target
.
response
||
response
.
target
.
responseText
).
split
(
'
\n
'
);
for
(
var
entry
in
response_list
)
{
if
(
response_list
[
entry
]
!==
""
)
{
rows
.
push
({
id
:
response_list
[
entry
],
value
:
{}
});
.
push
(
function
()
{
return
jIO
.
util
.
ajax
({
"
type
"
:
"
GET
"
,
"
url
"
:
url
});
})
.
push
(
function
(
data
)
{
var
data_list
=
JSON
.
parse
(
data
.
target
.
response
||
data
.
target
.
responseText
),
result_list
=
[],
data_entry
,
len
,
i
;
for
(
i
=
0
,
len
=
data_list
.
length
;
i
<
len
;
i
+=
1
)
{
data_entry
=
data_list
[
i
];
if
(
data_entry
.
path
!==
"
README.md
"
)
{
result_list
.
push
({
id
:
data_entry
.
download_url
,
value
:
{}
});
}
}
}
return
rows
;
});
return
result_list
;
});
};
jIO
.
addStorage
(
'
publisher_storage
'
,
PublisherStorage
);
}(
jIO
,
RSVP
,
JSON
,
UriTemplate
));
\ No newline at end of file
}(
jIO
,
RSVP
,
JSON
));
\ No newline at end of file
bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml
View file @
1622517c
...
...
@@ -337,7 +337,7 @@
</item>
<item>
<key>
<string>
configuration_content_security_policy
</string>
</key>
<value>
<string>
default-src \'self\'; img-src \'self\' * data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:
</string>
</value>
<value>
<string>
default-src \'self\'; img-src \'self\' * data:; media-src \'self\' blob:; connect-src \'self\'
https://raw.githubusercontent.com https://api.github.com
data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:
</string>
</value>
</item>
<item>
<key>
<string>
configuration_default_view_action_reference
</string>
</key>
...
...
@@ -614,7 +614,7 @@
</item>
<item>
<key>
<string>
serial
</string>
</key>
<value>
<string>
95
3.59466.37233.9915
</string>
</value>
<value>
<string>
95
4.25873.23492.36983
</string>
</value>
</item>
<item>
<key>
<string>
state
</string>
</key>
...
...
@@ -632,7 +632,7 @@
</tuple>
<state>
<tuple>
<float>
147
3847779.13
</float>
<float>
147
5681337.69
</float>
<string>
UTC
</string>
</tuple>
</state>
...
...
Write
Preview
Markdown
is supported
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