1
|
|
|
/* |
2
|
|
|
* CMS Pico - Integration of Pico within your files to create websites. |
3
|
|
|
* |
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
5
|
|
|
* later. See the COPYING file. |
6
|
|
|
* |
7
|
|
|
* @author Maxence Lange <[email protected]> |
8
|
|
|
* @copyright 2017 |
9
|
|
|
* @license GNU AGPL version 3 or any later version |
10
|
|
|
* |
11
|
|
|
* This program is free software: you can redistribute it and/or modify |
12
|
|
|
* it under the terms of the GNU Affero General Public License as |
13
|
|
|
* published by the Free Software Foundation, either version 3 of the |
14
|
|
|
* License, or (at your option) any later version. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU Affero General Public License for more details. |
20
|
|
|
* |
21
|
|
|
* You should have received a copy of the GNU Affero General Public License |
22
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
23
|
|
|
* |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** global: pico_elements */ |
28
|
|
|
|
29
|
|
|
var pico_nav = { |
30
|
|
|
|
31
|
|
|
updateNewWebsite: function (url) { |
32
|
|
|
pico_elements.cms_pico_new_url.text(define.nchost + define.sites + url); |
|
|
|
|
33
|
|
|
pico_nav.refreshNewFolder(); |
34
|
|
|
}, |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
pickFolderResult: function (folder) { |
38
|
|
|
pico_elements.cms_pico_new_folder_result = folder; |
39
|
|
|
pico_nav.refreshNewFolder(); |
40
|
|
|
}, |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
refreshNewFolder: function () { |
44
|
|
|
pico_elements.cms_pico_new_path.text(pico_elements.cms_pico_new_folder_result + '/' + |
45
|
|
|
pico_elements.cms_pico_new_website.val()); |
46
|
|
|
}, |
47
|
|
|
|
48
|
|
|
|
49
|
|
|
createNewWebsite: function () { |
50
|
|
|
|
51
|
|
|
var data = { |
52
|
|
|
name: pico_elements.cms_pico_new_name.val(), |
53
|
|
|
website: pico_elements.cms_pico_new_website.val(), |
54
|
|
|
path: pico_elements.cms_pico_new_path.text() |
55
|
|
|
}; |
56
|
|
|
|
57
|
|
|
$.ajax({ |
58
|
|
|
method: 'PUT', |
59
|
|
|
url: OC.generateUrl('/apps/cms_pico/personal/website'), |
|
|
|
|
60
|
|
|
data: { |
61
|
|
|
data: data |
62
|
|
|
} |
63
|
|
|
}).done(function (result) { |
64
|
|
|
pico_result.createNewWebsiteResult(result); |
|
|
|
|
65
|
|
|
}); |
66
|
|
|
|
67
|
|
|
}, |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
updateWebsiteOption: function (site_id, key, value) { |
71
|
|
|
$.ajax({ |
72
|
|
|
method: 'POST', |
73
|
|
|
url: OC.generateUrl('/apps/cms_pico/personal/website/' + site_id + '/option/' + key), |
|
|
|
|
74
|
|
|
data: { |
75
|
|
|
value: value |
76
|
|
|
} |
77
|
|
|
}).done(function (res) { |
78
|
|
|
pico_result.displayWebsites(res.websites); |
|
|
|
|
79
|
|
|
}); |
80
|
|
|
}, |
81
|
|
|
|
82
|
|
|
|
83
|
|
|
generateTmplWebsite: function (entry) { |
84
|
|
|
var tmpl = $('#tmpl_website').html(); |
85
|
|
|
|
86
|
|
|
tmpl = tmpl.replace(/%%id%%/g, entry.id); |
87
|
|
|
tmpl = tmpl.replace(/%%name%%/g, escapeHTML(entry.name)); |
88
|
|
|
tmpl = tmpl.replace(/%%address%%/g, define.nchost + define.sites + escapeHTML(entry.site)); |
|
|
|
|
89
|
|
|
tmpl = tmpl.replace(/%%path%%/g, escapeHTML(entry.path)); |
90
|
|
|
|
91
|
|
|
if (entry.options.private === '1') { |
92
|
|
|
tmpl = tmpl.replace(/%%private%%/g, escapeHTML(entry.options.private)); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
return tmpl; |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
|
99
|
|
|
}; |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.