source: OpenRLabs-Git/deploy/rlabs-docker/web2py-rlabs/applications/admin/views/default/design.html

main
Last change on this file was 42bd667, checked in by David Fuertes <dfuertes@…>, 4 years ago

Historial Limpio

  • Property mode set to 100755
File size: 22.8 KB
Line 
1{{extend 'layout.html'}}
2{{
3import re
4regex_space = re.compile('\s+')
5def all(items):
6    return reduce(lambda a,b:a and b,items,True)
7def peekfile(path,file,vars={},title=None):
8    args=(path,file) if 'app' in vars else (app,path,file)
9    return A(file.replace('\\\\','/'),_title=title,_href=URL('peek', args=args, vars=vars))
10def editfile(path,file,vars={}):
11    args=(path,file) if 'app' in vars else (app,path,file)
12    return A(SPAN(T('Edit')),_class='button editbutton btn btn-mini',_href=URL('edit', args=args, vars=vars))
13def testfile(path,file):
14    return A(TAG[''](IMG(_src=URL('static', 'images/test_icon.png'), _alt=T('test')),
15                        SPAN(T("Run tests in this file (to run all files, you may also use the button labelled 'test')"))),
16                        _class='icon test',
17                        _href=URL('test', args=(app, file)),
18                        _rel="tooltip",
19                        **{'_data-placement':'right',
20                            '_data-original-title':T("Run tests in this file (to run all files, you may also use the button labelled 'test')")})
21def editlanguagefile(path,file,vars={}):
22    return A(SPAN(T('Edit')),_class='button editbutton btn btn-mini',_href=URL('edit_language', args=(app, path, file), vars=vars))
23def editpluralsfile(path,file,vars={}):
24    return A(SPAN(T('Edit')),_class='button editbutton btn btn-mini',_href=URL('edit_plurals', args=(app, path, file), vars=vars))
25def file_upload_form(location, anchor=None):
26    form=FORM(
27            LABEL(T("upload file:")),
28            INPUT(_type="file",_name="file"),
29            LABEL(T("and rename it:")),
30            INPUT(_type="text",_name="filename",requires=IS_NOT_EMPTY(),_class=""),
31            DIV(TAG['BUTTON'](T("Upload"),_type="submit",_class="btn"),_class="controls"),
32            INPUT(_type="hidden",_name="location",_value=location),
33            INPUT(_type="hidden",_name="token",_value=session.token),
34            INPUT(_type="hidden",_name="sender",_value=URL('design',args=app, anchor=anchor)),
35            _action=URL('upload_file'),
36            _class="generatedbyw2p well well-small")
37    return form
38def file_create_form(location, anchor=None, helptext=""):
39    form=FORM(
40            LABEL(T("create file with filename:")),
41            INPUT(_type="text",_name="filename",requires=IS_NOT_EMPTY(),_class=''),
42            TAG['SMALL'](helptext,_class="help-block"),
43            DIV(TAG['BUTTON'](T("Create"),_type="submit",_class="btn"),_class="controls"),
44            INPUT(_type="hidden",_name="location",_value=location),
45            INPUT(_type="hidden",_name="sender",_value=URL('design',args=app)),
46            INPUT(_type="hidden",_name="token",_value=session.token),
47            INPUT(_type="hidden",_name="id",_value=anchor),
48            _action=URL('create_file'),
49            _class="generatedbyw2p well well-small")
50    return form
51def upload_plugin_form(app, anchor=None):
52    form=FORM(
53            LABEL(T("upload plugin file:")),
54            INPUT(_type="file",_name="pluginfile"),
55            INPUT(_type="hidden",_name="id",_value=anchor),
56            INPUT(_type="hidden",_name="token",_value=session.token),
57            DIV(TAG['BUTTON'](T("Upload"),_type="submit",_class="btn"),_class="controls"),
58            _class="generatedbyw2p well well-small")
59    return form
60def deletefile(arglist, vars={}):
61    vars.update({'sender':request.function+'/'+app})
62    return A(TAG[''](IMG(_src=URL('static', 'images/delete_icon.png')),
63                        SPAN(T('Delete this file (you will be asked to confirm deletion)'))),
64                        _href=URL('delete',args=arglist,vars=vars),
65                        _class='icon delete',
66                        _rel="tooltip",
67                        **{'_data-placement':'right',
68                            '_data-original-title':T('Delete this file (you will be asked to confirm deletion)')})
69}}
70{{block sectionclass}}design{{end}}
71<!-- begin "design" block -->
72
73<h2>{{=T("Edit application")}} "{{=A(app,_href=URL(app,'default','index'),_target="_blank")}}"</h2>
74
75<!-- COLLAPSE/JUMP-TO BUTTONS -->
76<div class="right-full controls">
77    <p class="buttons-row">
78    {{=searchbox('search')}}
79    <a class="button special btn btn-inverse" href="#" onclick="jQuery('h3>span').click();return false"><span>{{=T("collapse/expand all")}}</span></a>
80    <span class="buttongroup">
81    {{=button('#models', T("models"))}}
82    {{=button('#controllers', T("controllers"))}}
83    {{=button('#views', T("views"))}}
84    {{=button('#languages', T("languages"))}}
85    {{=button('#static', T("static"))}}
86    {{=button('#modules', T("modules"))}}
87    {{=button('#private', T("private files"))}}
88    {{=button('#plugins', T("plugins"))}}
89    </span>
90    </p>
91</div>
92
93<!-- MODELS -->
94<h3 id="_models" rel="pagebookmark">
95    <span class="component" onclick="collapse('models_inner');">{{=T("Models")}}</span>
96    <a href="#models" rel="tooltip" data-placement="right" data-original-title="{{=T('The data representation, define database tables and sets')}}">
97    {{=helpicon()}}
98    <span>{{=T("The data representation, define database tables and sets")}}</span>
99    </a><span id="models" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
100</h3>
101<div id="models_inner" class="component_contents">
102    {{if not models:}}<p><strong>{{=T("There are no models")}}</strong></p>{{else:}}
103    <div class="controls comptools">
104        {{=button(URL(a=app,c='appadmin',f='index'), T('database administration'))}}
105        {{if os.access(os.path.join(request.folder,'..',app,'databases','sql.log'),os.R_OK):}}
106            {{=button(URL('peek/%s/databases/sql.log'%app), 'sql.log')}}
107        {{pass}}
108        {{if os.access(os.path.join(request.folder,'..','admin','static','js','d3_graph.js'),os.R_OK):}}
109                {{=button(URL(a=app, c='appadmin',f='d3_graph_model'), T('graph model'))}}
110        {{pass}}
111    </div>
112    <ul class="unstyled act_edit">
113        {{for m in models:}}
114            {{id="models__"+m.replace('.','__')}}
115        <li id="{{='_'+id}}" rel="pagebookmark"><span id="{{=id}}" class="hashstick">&nbsp;</span>
116            <span class="filetools controls">
117                {{=editfile('models',m, dict(id=id))}}
118                {{=deletefile([app, 'models', m], dict(id=id, id2='models'))}}
119            </span>
120            <span class="file">
121                {{=peekfile('models',m, dict(id=id))}}
122            </span>
123            <span class="extras">
124                {{if len(defines[m]):}}{{=T("defines tables")}} {{pass}}{{=XML(b', '.join([B(table).xml() for table in defines[m]]))}}
125            </span>
126        </li>
127        {{pass}}
128    </ul>
129    {{pass}}
130    <div class="controls formfield">
131      <button onclick="jQuery('#form1').slideToggle()" class="btn btn-mini">{{=T('Create')}}</button>
132      <div id="form1" class="row-fluid" style="display:none">
133        <div class="span3">{{=file_create_form('%s/models/' % app, 'models')}}</div>
134      </div>
135    </div>
136</div>
137<!-- FIND CONTROLLER FUNCTIONS -->
138{{
139controller_functions=[]
140for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functions[c]]
141}}
142
143<!-- CONTROLLERS -->
144<h3 id="_controllers" rel="pagebookmark">
145    <span class="component" onclick="collapse('controllers_inner');">{{=T("Controllers")}}</span>
146    <a href="#controllers" rel="tooltip" data-placement="right" data-original-title="{{=T('The application logic, each URL path is mapped in one exposed function in the controller')}}">
147    {{=helpicon()}}
148    <span>{{=T("The application logic, each URL path is mapped in one exposed function in the controller")}}</span>
149    </a><span id="controllers" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
150</h3>
151<div id="controllers_inner" class="component_contents">
152    {{if not controllers:}}<p><strong>{{=T("There are no controllers")}}</strong></p>{{else:}}
153    <div class="controls comptools">
154        {{=button(URL('test',args=app), T("test"))}}
155        {{=button(URL('edit',args=[app,'cron','crontab']), T("crontab"))}}
156    </div>
157    <ul class="unstyled act_edit">
158        {{for c in controllers:}}
159        {{id="controllers__"+c.replace('.','__')}}
160        <li id="{{='_'+id}}" rel="pagebookmark"><span id="{{=id}}" class="hashstick">&nbsp;</span>
161        <span class="filetools controls">
162        {{=editfile('controllers',c, dict(id=id))}}
163        {{=deletefile([app, 'controllers', c], dict(id=id, id2='controllers'))}}
164        {{=testfile('controllers',c)}}
165        </span>
166        <span class="file">
167        {{=peekfile('controllers',c, dict(id=id))}}
168        </span>
169        <span class="extras celled">
170            {{if functions[c]:}}{{=T("exposes")}}{{pass}} {{=XML(b', '.join([A(f,_href=URL(a=app,c=c[:-3],f=f)).xml() for f in functions[c]]))}}
171        </span>
172        </li>
173        {{pass}}
174    </ul>
175    {{pass}}
176    <div class="controls formfield">
177      <button onclick="jQuery('#form2').slideToggle()" class="btn btn-mini">{{=T('Create')}}</button>
178      <div id="form2" class="row-fluid" style="display:none">
179        <div class="span3">{{=file_create_form('%s/controllers/' % app, 'controllers')}}</div>
180      </div>
181    </div>
182</div>
183
184<!-- VIEWS -->
185<h3 id="_views" rel="pagebookmark">
186    <span class="component" onclick="collapse('views_inner');">{{=T("Views")}}</span>
187    <a href="#views" rel="tooltip" data-placement="right" data-original-title="{{=T('The presentations layer, views are also known as templates')}}">
188    {{=helpicon()}}
189    <span>{{=T("The presentations layer, views are also known as templates")}}</span>
190    </a><span id="views" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
191</h3>
192<div id="views_inner" class="component_contents">
193  {{if not views:}}<p><strong>{{=T("There are no views")}}</strong></p>{{else:}}
194    <div class="controls comptools">
195        {{=button(LAYOUTS_APP, T("Download layouts from repository"))}}
196    </div>
197    <ul class="unstyled act_edit">
198        {{for c in views:}}
199            {{id="views__"+c.replace('/','__').replace('.','__')}}
200        <li id="{{='_'+id}}" rel="pagebookmark"><span id="{{=id}}" class="hashstick">&nbsp;</span>
201            <span class="filetools controls">
202                {{=editfile('views',c, dict(id=id))}}
203                {{=deletefile([app, 'views', c], dict(id=id, id2='views'))}}
204            </span>
205            <span class="file">
206                {{=peekfile('views',c, dict(id=id))}}
207            </span>
208            <span class="extras celled celled-one">
209                {{if c in extend:}}{{=T("extends")}} <b>{{=extend[c]}}</b> {{pass}}
210                {{if include[c]:}}{{=T("includes")}} {{pass}}{{=XML(b', '.join([B(f).xml() for f in include[c]]))}}
211            </span>
212        </li>
213        {{pass}}
214    </ul>
215    {{pass}}
216    <div class="controls formfield">
217      <button onclick="jQuery('#form3').slideToggle()" class="btn btn-mini">{{=T('Create')}}</button>
218      <div id="form3" class="row-fluid" style="display:none">
219        <div class="span3">{{=file_create_form('%s/views/' % app, 'views')}}</div>
220      </div>
221    </div>
222</div>
223
224<!-- LANGUAGES -->
225<h3 id="_languages" rel="pagebookmark">
226    <span class="component" onclick="collapse('languages_inner');">{{=T("Languages")}}</span>
227    <a href="#languages" rel="tooltip" data-placement="right" data-original-title="{{=T('Translation strings for the application')}}">
228    {{=helpicon()}}
229    <span>{{=T("Translation strings for the application")}}</span>
230    </a><span id="languages" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
231</h3>
232<div id="languages_inner" class="component_contents">
233    {{if not languages:}}<p><strong>{{=T("There are no translators, only default language is supported")}}</strong></p>{{else:}}
234    <div class="controls comptools">
235        {{=button(URL('update_languages/'+app), T('update all languages'))}}
236    </div>
237    <ul class="unstyled act_edit">
238        {{for lang in sorted(languages):
239            file = lang+'.py'
240            id = "languages__"+file.replace('.','__')}}
241        <li id="{{='_'+id}}" rel="pagebookmark" class="li-row"><span id="{{=id}}" class="hashstick">&nbsp;</span>
242            <span class="li-controls">
243                <span class="filetools controls">
244                 {{=editlanguagefile('languages',file)}}
245                 {{=deletefile([app, 'languages', file], dict(id=id, id2='languages'))}}
246                </span>
247                <span class="">
248                  {{=peekfile('languages',file, dict(id=id))}}
249                </span>
250            </span> <!-- /li-row -->
251            <span class="extras celled">
252                (
253                {{=T("Plural-Forms:")}}
254                {{p=languages[lang][3:7]}}
255                {{if p[2] == 'default':}}
256                   <span class='error text-error'>{{=T("rules are not defined")}}</span> {{=T.M("(file **gluon/contrib/plural_rules/%s.py** is not found)",lang[:2])}}
257                {{else:}}
258                 {{if p[3] == 1:}}
259                   {{=B(T("are not used"))}}
260                 {{else:}}
261                   {{pfile=p[0]}}
262                    {{if p[1]!=0:}}<span style="display:inline-block;margin-top:-10px;">
263                     <span class="filetools controls">
264                       {{=editpluralsfile('languages',pfile,dict(nplurals=p[3]))}}
265                     </span>
266                     <span class="file">
267                        {{=peekfile('languages',pfile,dict(id=id))}}
268                     </span></span>
269                   {{else:}}
270                      <b>{{=T("are not used yet")}}</b>
271                    {{pass}}
272                  {{pass}}
273                {{pass}}
274                )
275            </span>
276        </li>
277        {{pass}}
278    </ul>
279    {{pass}}
280    <div class="controls formfield">
281      <button onclick="jQuery('#form4').slideToggle()" class="btn btn-mini">{{=T('Create')}}</button>
282      <div id="form4" class="row-fluid" style="display:none">
283        <div class="span3">{{=file_create_form('%s/languages/' % app, 'languages', T('(something like "it-it")'))}}</div>
284      </div>
285    </div>
286</div>
287
288<!-- STATIC -->
289<h3 id="_static" rel="pagebookmark">
290    <span class="component" onclick="collapse('static_inner');">{{=T("Static")}}</span>
291    <a href="#static" rel="tooltip" data-placement="right" data-original-title="{{=T('These files are served without processing, your images go here')}}">
292    {{=helpicon()}}
293    <span>{{=T("These files are served without processing, your images go here")}}</span>
294    </a><span id="static" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
295</h3>
296<div id="static_inner" class="component_contents">
297    {{if not statics:}}<p><strong>{{=T("There are no static files")}}</strong></p>{{else:}}
298    <ul class="unstyled act_edit">
299    {{
300        path=[]
301        for file in statics+['']:
302            items=file.split('/')
303            file_path=items[:-1]
304            filename=items[-1]
305            while path!=file_path:
306                if len(file_path)>=len(path) and all([v==file_path[k] for k,v in enumerate(path)]):
307                    path.append(file_path[len(path)])
308                    thispath = regex_space.sub('-', 'static__'+'__'.join(path))
309    }}
310        <li class="folder"><i>&nbsp;</i>
311            <a href="javascript:collapse('{{=thispath}}');" class="file">{{=path[-1]}}/</a>
312            <ul id="{{=thispath}}" style="display: none;" class="sublist">{{
313                else:
314                    path = path[:-1]
315        }}
316        </ul></li>
317    {{
318                pass
319            pass
320        if filename:
321    }}
322        <li>
323            <span class="filetools controls">
324                {{=editfile('static',file, dict(id="static"))}} {{=deletefile([app,'static',file], dict(id="static",id2="static"))}}
325            </span>
326            <span class="file">
327                <a href="{{=URL(a=app,c='static',f=file)}}">{{=filename}}</a>
328            </span>
329        </li>{{
330        pass
331    pass
332    }}
333    </ul>
334    {{pass}}
335    <div class="controls formfield">
336      <button onclick="jQuery('#form5').slideToggle()" class="btn btn-mini">{{=T('Create/Upload')}}</button>
337      <div id="form5" class="row-fluid" style="display:none">
338        <div class="span3">{{=file_create_form('%s/static/' % app, 'static')}}<em>{{=T('or alternatively')}}</em></div>
339        <div class="span3">{{=file_upload_form('%s/static/' % app, 'static')}}</div>
340      </div>
341    </div>
342</div>
343
344<!-- MODULES -->
345<h3 id="_modules" rel="pagebookmark">
346    <span class="component" onclick="collapse('modules_inner');">{{=T("Modules")}}</span>
347    <a href="#modules" rel="tooltip" data-placement="right" data-original-title="{{=T('Additional code for your application')}}">
348    {{=helpicon()}}
349    <span>{{=T("Additional code for your application")}}</span>
350    </a><span id="modules" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
351</h3>
352<div id="modules_inner" class="component_contents">
353    {{if not modules:}}<p><strong>{{=T("There are no modules")}}</strong></p>{{else:}}
354    <ul class="unstyled act_edit">
355        {{for m in modules:}}
356            {{id="modules__"+m.replace('/','__').replace('.','__')}}
357        <li id="{{='_'+id}}" rel="pagebookmark"><span id="{{=id}}" class="hashstick">&nbsp;</span>
358            <span class="filetols controls">
359                {{=editfile('modules',m,dict(id=id))}}
360                {{if m!='__init__.py':}}
361                    {{=deletefile([app, 'modules', m], dict(id=id, id2='modules'))}}
362                {{pass}}
363            </span>
364            <span class="file">
365                {{=peekfile('modules',m, dict(id=id))}}
366            </span>
367        </li>
368        {{pass}}
369    </ul>
370    {{pass}}
371    <div class="controls formfield">
372      <button onclick="jQuery('#form6').slideToggle()" class="btn btn-mini">{{=T('Create/Upload')}}</button>
373      <div id="form6" class="row-fluid" style="display:none">
374        <div class="span3">{{=file_create_form('%s/modules/' % app, 'modules')}}<em>{{=T('or alternatively')}}</em></div>
375        <div class="span3">{{=file_upload_form('%s/modules/' % app, 'modules')}}</div>
376      </div>
377    </div>
378</div>
379
380<!-- PRIVATE -->
381<h3 id="_private" rel="pagebookmark">
382    <span class="component" onclick="collapse('private_inner');">{{=T("Private files")}}</span>
383    <a href="#private" rel="tooltip" data-placement="right" data-original-title="{{=T('These files are not served, they are only available from within your app')}}">
384    {{=helpicon()}}
385    <span>{{=T("These files are not served, they are only available from within your app")}}</span>
386    </a><span id="private" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
387</h3>
388<div id="private_inner" class="component_contents">
389    {{if not privates:}}<p><strong>{{=T("There are no private files")}}</strong></p>{{else:}}
390    <ul class="unstyled act_edit">
391        {{
392        path=[]
393        for file in privates+['']:
394            items=file.split('/')
395            file_path=items[:-1]
396            filename=items[-1]
397            while path!=file_path:
398                if len(file_path)>=len(path) and all([v==file_path[k] for k,v in enumerate(path)]):
399                    path.append(file_path[len(path)])
400                    thispath='private__'+'__'.join(path)
401        }}
402        <li class="folder">
403            <a href="javascript:collapse('{{=thispath}}');" class="file">{{=path[-1]}}/</a>
404            <ul id="{{=thispath}}" style="display: none;" class="sublist">{{
405                else:
406                    path = path[:-1]
407            }}
408            </ul>
409        </li>
410        {{
411                pass
412            pass
413            if filename:
414        }}
415        <li>
416            <span class="filetools controls">
417                {{=editfile('private',file, dict(id="private"))}} {{=deletefile([app,'private',file], dict(id="private",id2="private"))}}
418            </span>
419            <span class="file">
420                {{=peekfile('private',file, dict(id="private"))}}
421            </span>
422        </li>{{
423            pass
424        pass
425        }}
426    {{pass}}
427    </ul>
428    <div class="controls formfield">
429      <button onclick="jQuery('#form7').slideToggle()" class="btn btn-mini">{{=T('Create/Upload')}}</button>
430      <div id="form7" class="row-fluid" style="display:none">
431        <div class="span3">{{=file_create_form('%s/private/' % app, 'private')}}<em>{{=T('or alternatively')}}</em></div>
432        <div class="span3">{{=file_upload_form('%s/private/' % app, 'private')}}</div>
433      </div>
434    </div>
435</div>
436
437<!-- PLUGINS -->
438<h3 id="_plugins" rel="pagebookmark">
439    <span class="component" onclick="collapse('plugins_inner');">{{=T("Plugins")}}</span>
440    <a href="#plugins" rel="tooltip" data-placement="right" data-original-title="{{=T('To create a plugin, name a file/folder plugin_[name]')}}">
441    {{=helpicon()}}
442    <span>{{=T("To create a plugin, name a file/folder plugin_[name]")}}</span>
443    </a><span id="plugins" class="hashstick">&nbsp;</span><a href="#" class="tophashlink btn btn-mini btn-warning"><span>top</span></a>
444</h3>
445<div id="plugins_inner" class="component_contents">
446    {{if plugins:}}
447    <ul class="unstyled act_edit">
448        {{for plugin in plugins:}}
449            {{id="plugins__"+plugin.replace('/','__').replace('.','__')}}
450        <li id="{{=id}}">
451            {{=A('plugin_%s' % plugin, _class='file', _href=URL('plugin', args=[app, plugin], vars=dict(id=id, id2='plugins')))}}
452        </li>
453        {{pass}}
454    </ul>
455    {{else:}}
456    <p><strong>{{=T('There are no plugins')}}</strong></p>
457    {{pass}}
458    <div class="controls comptools">
459        {{=button(URL(c="default", f="plugins", args=[app,]), T('Download plugins from repository'))}}
460    </div>
461    <div class="controls formfield">
462      <button onclick="jQuery('#form8').slideToggle()" class="btn btn-mini">{{=T('Upload')}}</button>
463      <div id="form8" class="row-fluid" style="display:none">
464        <div class="row-fluid">
465          <div class="span3">{{=upload_plugin_form(app, 'plugins')}}</div>
466        </div>
467      </div>
468</div>
469
470<script>
471function filter_files() {
472      if(jQuery('#search').val()){
473        jQuery.getJSON('{{=URL('search',args=request.args)}}?keywords='+escape(jQuery('#search').val()),null,function(data, textStatus, xhr){
474          jQuery('.component_contents li, .formfield, .comptools').hide();
475          files=data['files'];
476          message=data['message'];
477          for(var i=0; i<files.length; i++)
478            jQuery('li#_'+files[i].replace(/\//g,'__').replace('.','__')).slideDown();
479          jQuery('.w2p_flash').html(message).slideDown();
480          });
481      } else {
482          jQuery('.component_contents li, .formfield, .comptools').slideDown();
483          jQuery('.w2p_flash').html('').hide();
484      }
485}
486jQuery(document).ready(function(){
487   jQuery('#search').keyup(function(e){
488      var code = (e.keyCode ? e.keyCode : e.which);
489      if(code==13) filter_files();
490   });
491   jQuery('#search_start').click(function(e){ filter_files(); });
492});
493</script>
494<!-- end "design" block -->
Note: See TracBrowser for help on using the repository browser.