-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathsample-designer.html
213 lines (185 loc) · 8.36 KB
/
sample-designer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>API Designer</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- build:css({.,.tmp,app}) styles/main.css -->
<link rel="stylesheet" href="vendor/styles/font-awesome.css">
<link rel="stylesheet" href="vendor/styles/codemirror.css">
<link rel="stylesheet" href="vendor/styles/solarized.css">
<link rel="stylesheet" href="vendor/styles/show-hint.css">
<link rel="stylesheet" href="bower_components/api-console/dist/styles/app.css">
<link rel="stylesheet" href="styles/css/main.css">
<link rel="stylesheet" href="styles/css/shelf.css">
<link rel="stylesheet" href="styles/css/errors.css">
<link rel="stylesheet" href="styles/css/file-browser.css">
<link rel="stylesheet" href="styles/css/console-overrides.css">
<link rel="stylesheet" href="styles/css/code-mirror-overrides.css">
<link rel="stylesheet" href="styles/css/font-awesome-overrides.css">
<link rel="stylesheet" href="styles/css/modal.css">
<!-- endbuild -->
</head>
<body ng-app="ramlEditorApp" class="{{$root.theme}}">
<div class="container" ng-include src="'views/raml-editor-main.tmpl.html'"></div>
<!-- build:js({.,.tmp,app}) scripts/vendor.js -->
<script src="vendor/scripts/codemirror.js"></script>
<script src="vendor/scripts/foldcode.js"></script>
<script src="vendor/scripts/foldgutter.js"></script>
<script src="vendor/scripts/gfm.js"></script>
<script src="vendor/scripts/javascript.js"></script>
<script src="vendor/scripts/markdown.js"></script>
<script src="vendor/scripts/overlay.js"></script>
<script src="vendor/scripts/show-hint.js"></script>
<script src="vendor/scripts/xml.js"></script>
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-cookies/angular-cookies.js"></script>
<script src="bower_components/angular-resource/angular-resource.js"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
<script src="bower_components/angular-bootstrap/ui-bootstrap-tpls.js"></script>
<script src="bower_components/es5-shim/es5-shim.js"></script>
<script src="bower_components/showdown/src/showdown.js"></script>
<script src="bower_components/showdown/src/extensions/table.js"></script>
<script src="bower_components/raml-js-parser/dist/raml-parser.js"></script>
<script src="bower_components/api-console/dist/scripts/vendor/jquery.js"></script>
<script src="bower_components/api-console/dist/scripts/vendor/vkbeautify.js"></script>
<script src="bower_components/api-console/dist/scripts/app.js"></script>
<script src="bower_components/raml-grammar/dist/suggest.js"></script>
<!-- endbuild -->
<!-- build:js({.,.tmp,app}) scripts/scripts.js -->
<script src="scripts/app.js"></script>
<script src="scripts/services/utils.js"></script>
<script src="scripts/services/config.js"></script>
<script src="scripts/services/lightweight-dom.js"></script>
<script src="scripts/services/lightweight-parse.js"></script>
<script src="scripts/services/code-folding.js"></script>
<script src="scripts/services/code-mirror.js"></script>
<script src="scripts/services/code-mirror-errors.js"></script>
<script src="scripts/services/event.js"></script>
<script src="scripts/services/raml-hint.js"></script>
<script src="scripts/services/raml-snippets.js"></script>
<script src="scripts/services/raml-highlight.js"></script>
<script src="scripts/services/raml-highlight-config.js"></script>
<script src="scripts/services/raml-repository.js"></script>
<script src="scripts/services/request-executor.js"></script>
<script src="scripts/services/request-builder.js"></script>
<script src="scripts/services/file-system.js"></script>
<script src="scripts/services/mock-file-system.js"></script>
<script src="scripts/filters/string-filters.js"></script>
<script src="scripts/controllers/raml-editor-main.js"></script>
<script src="scripts/controllers/raml-editor-shelf.js"></script>
<script src="scripts/controllers/notifications.js"></script>
<!-- endbuild -->
<script>
// This part is needed only if you want to provide your own Persistance Implementation
// Angular Module must match "ramlEditorApp"
angular.module('ramlEditorApp')
.factory('MyFileSystem', function ($http, $q, config, eventService) {
var service = {};
var files = {};
service.directory = function (path) {
var deferred = $q.defer();
$http({
method: 'GET',
data: '',
url : 'http://localhost:3000/files',
withCredentials: false
}).success(function (data, status, headers, config) {
Object.keys(files).forEach(function (key) {
delete files[key];
});
Object.keys(data).forEach(function (id) {
files[data[id].name] = id;
});
deferred.resolve(Object.keys(files));
})
.error(deferred.reject.bind(deferred));
return deferred.promise;
};
service.load = function (path, name) {
var deferred = $q.defer();
$http({
method: 'GET',
data: '',
url : 'http://localhost:3000/files/'+files[name],
withCredentials: false
}).success(function (data, status, headers, config) {
deferred.resolve(decodeURI(data.contents));
})
.error(deferred.reject.bind(deferred));
return deferred.promise;
};
service.remove = function (path, name) {
var deferred = $q.defer();
if (!files[name]) {
deferred.reject('file with name="' + name + '" does not exist');
return deferred.promise;
}
$http({
method: 'DELETE',
data: '',
url : 'http://localhost:3000/files/'+files[name],
withCredentials: false
}).success(function (data, status, headers, config) {
delete files[name];
deferred.resolve();
})
.error(deferred.reject.bind(deferred));
return deferred.promise;
};
service.save = function (path, name, contents) {
var deferred = $q.defer();
var payload = new Object();
var fileId = files[name];
payload["name"] = name;
payload["path"] = path;
payload["contents"] = encodeURI(contents);
// Existing file
if (fileId) {
$http({
method: 'PUT',
data: JSON.stringify(payload),
url : 'http://localhost:3000/files/'+fileId,
withCredentials: false
}).success(deferred.resolve.bind(deferred))
.error(deferred.reject.bind(deferred));
}
// New File
else {
$http({
method: 'POST',
data: JSON.stringify(payload),
url : 'http://localhost:3000/files/',
withCredentials: false
}).success(function (data, status, headers, config) {
files[name] = data._id;
deferred.resolve({entry: name, content: payload["contents"], id: data._id});
})
.error(deferred.reject.bind(deferred));
}
return deferred.promise;
};
return service;
})
.run(function (MyFileSystem, config, eventService) {
// Set MyFileSystem as the filesystem to use
config.set('fsFactory', 'MyFileSystem');
// In case you want to send notifications to the user
// (for instance, that he must login to save).
// The expires flags means whether
// it should be hidden after a period of time or the
// user should dismiss it manually.
eventService.broadcast('event:notification',
{message: 'File saved.', expires: true});
});
</script>
</body>
</html>