-
Notifications
You must be signed in to change notification settings - Fork 38
/
t.html
178 lines (150 loc) · 3.73 KB
/
t.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
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.8.0/styles/default.min.css">
<script>hljs.initHighlightingOnLoad();</script>
</head>
<body>
<script>
function escapeRegExp(string) {
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function replaceAll(string, find, replace) {
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function sar( ) {
var templateString = $("#template_pre").text();
var newName= $("#newName").val();
var newContents = replaceAll(templateString, "TEMPLATE", newName );
$("#template_output").text( newContents);
$('#template_output').each(function(i, block) {
hljs.highlightBlock(block);
});
}
</script>
New collection name (in singular form, e.g. "product") and press TAB.
<input id="newName" type="text" name="template_name" onChange="sar();" />
<div id="template">
<pre><code class="json" id="template_output">
{ "here" : "it comes" }
</code>
</pre>
<pre id="template_pre" style="display:none;">
// copy to application.json / "collections":
{
"name":"TEMPLATEs",
"type":"collection",
"fields":[
{
"name":"name",
"title":"Name",
"type":"string",
"exportable":true
}
]
}
// copy to application.json / "queries":
{
"name":"TEMPLATEs",
"collection":"TEMPLATEs"
},
{
"name":"TEMPLATE",
"collection":"TEMPLATEs",
"find_one":true,
"filter":{
"_id":":TEMPLATEId"
}
},
{
"name":"TEMPLATEs_empty",
"collection":"TEMPLATEs",
"find_one":true,
"filter":{
"_id":null
}
}
// copy to application.json / "pages":
{
"name":"TEMPLATEs",
"type":"page",
"components":[
{
"name":"view",
"query_name":"TEMPLATEs",
"insert_route":"TEMPLATEs.insert",
"details_route":"TEMPLATEs.details",
"edit_route":"TEMPLATEs.edit",
"type":"data_view",
"details_route_params":[
{
"name":"TEMPLATEId",
"value":"this._id"
}
],
"edit_route_params":[
{
"name":"TEMPLATEId",
"value":"this._id"
}
]
}
],
"pages":[
{
"name":"insert",
"type":"page",
"components":[
{
"name":"insert_form",
"title":"New TEMPLATE",
"query_name":"TEMPLATEs_empty",
"mode":"insert",
"submit_route":"TEMPLATEs",
"cancel_route":"TEMPLATEs",
"type":"form"
}
]
},
{
"name":"details",
"route_params":[
"TEMPLATEId"
],
"type":"page",
"components":[
{
"name":"details_form",
"query_name":"TEMPLATE",
"mode":"read_only",
"close_route":"TEMPLATEs",
"back_route":"TEMPLATEs",
"type":"form"
}
]
},
{
"name":"edit",
"route_params":[
"TEMPLATEId"
],
"type":"page",
"components":[
{
"name":"edit_form",
"title":"Edit TEMPLATE",
"query_name":"TEMPLATE",
"mode":"update",
"submit_route":"TEMPLATEs",
"cancel_route":"TEMPLATEs",
"type":"form"
}
]
}
]
}
</pre>
</div>
</body>
</html>