##// END OF EJS Templates
gists: block id input for public gists....
super-admin -
r4691:52d2949f stable
parent child Browse files
Show More
@@ -1,147 +1,147 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 %if c.show_private:
6 6 ${_('Private Gists for user {}').format(c.rhodecode_user.username)}
7 7 %elif c.show_public:
8 8 ${_('Public Gists for user {}').format(c.rhodecode_user.username)}
9 9 %else:
10 10 ${_('Public Gists')}
11 11 %endif
12 12 %if c.rhodecode_name:
13 13 &middot; ${h.branding(c.rhodecode_name)}
14 14 %endif
15 15 </%def>
16 16
17 17 <%def name="breadcrumbs_links()"></%def>
18 18
19 19 <%def name="menu_bar_nav()">
20 20 ${self.menu_items(active='gists')}
21 21 </%def>
22 22
23 23 <%def name="main()">
24 24
25 25 <div class="box">
26 26 <div class="title">
27 27
28 28 <ul class="button-links">
29 29 % if c.is_super_admin:
30 <li class="btn ${h.is_active('all', c.active)}"><a href="${h.route_path('gists_show', _query={'all': 1})}">${_('All gists')}</a></li>
30 <li><a class="btn ${h.is_active('all', c.active)}" href="${h.route_path('gists_show', _query={'all': 1})}">${_('All gists')}</a></li>
31 31 %endif
32 <li class="btn ${h.is_active('public', c.active)}"><a href="${h.route_path('gists_show')}">${_('All public')}</a></li>
32 <li><a class="btn ${h.is_active('public', c.active)}" href="${h.route_path('gists_show')}">${_('All public')}</a></li>
33 33 %if c.rhodecode_user.username != h.DEFAULT_USER:
34 <li class="btn ${h.is_active('my_all', c.active)}"><a href="${h.route_path('gists_show', _query={'public':1, 'private': 1})}">${_('My gists')}</a></li>
35 <li class="btn ${h.is_active('my_private', c.active)}"><a href="${h.route_path('gists_show', _query={'private': 1})}">${_('My private')}</a></li>
36 <li class="btn ${h.is_active('my_public', c.active)}"><a href="${h.route_path('gists_show', _query={'public': 1})}">${_('My public')}</a></li>
34 <li><a class="btn ${h.is_active('my_all', c.active)}" href="${h.route_path('gists_show', _query={'public':1, 'private': 1})}">${_('My gists')}</a></li>
35 <li><a class="btn ${h.is_active('my_private', c.active)}" href="${h.route_path('gists_show', _query={'private': 1})}">${_('My private')}</a></li>
36 <li><a class="btn ${h.is_active('my_public', c.active)}" href="${h.route_path('gists_show', _query={'public': 1})}">${_('My public')}</a></li>
37 37 %endif
38 38 </ul>
39 39
40 40 % if c.rhodecode_user.username != h.DEFAULT_USER:
41 41 <div class="pull-right">
42 42 <a class="btn btn-primary" href="${h.route_path('gists_new')}" >
43 43 ${_(u'Create New Gist')}
44 44 </a>
45 45 </div>
46 46 % endif
47 47
48 48 <div class="grid-quick-filter">
49 49 <ul class="grid-filter-box">
50 50 <li class="grid-filter-box-icon">
51 51 <i class="icon-search"></i>
52 52 </li>
53 53 <li class="grid-filter-box-input">
54 54 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/>
55 55 </li>
56 56 </ul>
57 57 </div>
58 58
59 59 </div>
60 60
61 61 <div class="main-content-full-width">
62 62 <div id="repos_list_wrap">
63 63 <table id="gist_list_table" class="display"></table>
64 64 </div>
65 65 </div>
66 66
67 67 </div>
68 68
69 69 <script type="text/javascript">
70 70 $(document).ready(function() {
71 71
72 72 var get_datatable_count = function(){
73 73 var api = $('#gist_list_table').dataTable().api();
74 74 $('#gists_count').text(api.page.info().recordsDisplay);
75 75 };
76 76
77 77
78 78 // custom filter that filters by access_id, description or author
79 79 $.fn.dataTable.ext.search.push(
80 80 function( settings, data, dataIndex ) {
81 81 var query = $('#q_filter').val();
82 82 var author = data[0].strip();
83 83 var access_id = data[2].strip();
84 84 var description = data[3].strip();
85 85
86 86 var query_str = (access_id + " " + author + " " + description).toLowerCase();
87 87
88 88 if(query_str.indexOf(query.toLowerCase()) !== -1){
89 89 return true;
90 90 }
91 91 return false;
92 92 }
93 93 );
94 94
95 95 // gists list
96 96 $('#gist_list_table').DataTable({
97 97 data: ${c.data|n},
98 98 dom: 'rtp',
99 99 pageLength: ${c.visual.dashboard_items},
100 100 order: [[ 4, "desc" ]],
101 101 columns: [
102 102 { data: {"_": "author",
103 103 "sort": "author_raw"}, title: "${_("Author")}", width: "250px", className: "td-user" },
104 104 { data: {"_": "type",
105 105 "sort": "type"}, title: "${_("Type")}", width: "100px", className: "td-gist-type" },
106 106 { data: {"_": "access_id",
107 107 "sort": "access_id"}, title: "${_("Name")}", width:"150px", className: "td-componentname" },
108 108 { data: {"_": "description",
109 109 "sort": "description"}, title: "${_("Description")}", width: "250px", className: "td-description" },
110 110 { data: {"_": "created_on",
111 111 "sort": "created_on_raw"}, title: "${_("Created on")}", className: "td-time" },
112 112 { data: {"_": "expires",
113 113 "sort": "expires"}, title: "${_("Expires")}", width: "200px", className: "td-expire" }
114 114 ],
115 115 language: {
116 116 paginate: DEFAULT_GRID_PAGINATION,
117 117 emptyTable: _gettext("No gists available yet.")
118 118 },
119 119 "initComplete": function( settings, json ) {
120 120 timeagoActivate();
121 121 tooltipActivate();
122 122 get_datatable_count();
123 123 }
124 124 });
125 125
126 126 // update the counter when things change
127 127 $('#gist_list_table').on('draw.dt', function() {
128 128 timeagoActivate();
129 129 tooltipActivate();
130 130 get_datatable_count();
131 131 });
132 132
133 133 // filter, filter both grids
134 134 $('#q_filter').on( 'keyup', function () {
135 135 var repo_api = $('#gist_list_table').dataTable().api();
136 136 repo_api
137 137 .draw();
138 138 });
139 139
140 140 // refilter table if page load via back button
141 141 $("#q_filter").trigger('keyup');
142 142
143 143 });
144 144
145 145 </script>
146 146 </%def>
147 147
@@ -1,103 +1,112 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.mako"/>
3 3
4 4 <%def name="title()">
5 5 ${_('New Gist')}
6 6 %if c.rhodecode_name:
7 7 &middot; ${h.branding(c.rhodecode_name)}
8 8 %endif
9 9 </%def>
10 10
11 11 <%def name="breadcrumbs_links()"></%def>
12 12
13 13 <%def name="menu_bar_nav()">
14 14 ${self.menu_items(active='gists')}
15 15 </%def>
16 16
17 17 <%def name="main()">
18 18 <div class="box">
19 19 <!-- box / title -->
20 20 <div class="title">
21 21
22 22 </div>
23 23
24 24 <div class="table">
25 25 <div id="files_data">
26 26 ${h.secure_form(h.route_path('gists_create'), id='eform', request=request)}
27 27 <div>
28 28 <span class="gist-gravatar">
29 29 ${self.gravatar(c.rhodecode_user.email, 30)}
30 30 </span>
31 31 <label for='gistid'>${_('Gist id')}</label>
32 32 ${h.text('gistid', placeholder=_('Auto generated'))}
33 33
34 34 <label for='lifetime'>${_('Gist lifetime')}</label>
35 35 ${h.dropdownmenu('lifetime', '', c.lifetime_options)}
36 36
37 37 <label for='acl_level'>${_('Private Gist access level')}</label>
38 38 ${h.dropdownmenu('gist_acl_level', '', c.acl_options)}
39 39
40 40 <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea>
41 41 </div>
42 42
43 43 <div id="codeblock" class="codeblock">
44 44 <div class="code-header">
45 45 <div class="form">
46 46 <div class="fields">
47 47 ${h.text('filename', size=30, placeholder=_('name gist file...'))}
48 48 ${h.dropdownmenu('mimetype','plain',[('plain',_('plain'))],enable_filter=True)}
49 49 </div>
50 50 </div>
51 51 </div>
52 52
53 53 <div id="editor_container">
54 54 <div id="editor_pre"></div>
55 55 <textarea id="editor" name="content" ></textarea>
56 56 </div>
57 57 </div>
58 58
59 59 <div class="pull-left">
60 60 <div class="pull-right">
61 61 ${h.submit('create',_('Create Gist'),class_="btn")}
62 62 </div>
63 63 <div class="rcform-element pull-right">
64 64 <div class="fields gist-type-fields">
65 65 <fieldset>
66 66 <div class="gist-type-fields-wrapper">
67 67
68 <input type="radio" id="private_gist" checked="" name="gist_type" value="private">
68 <input type="radio" id="private_gist" checked="" name="gist_type" value="private" onchange="setGistId('private')">
69 69 <label for="private_gist">${_('Private Gist')}</label>
70 70 <span class="tooltip label" title="${_('Private Gists are not listed and only accessible through their secret url.')}">${_('Private Gist')}</span>
71 71
72 <input type="radio" id="public_gist" name="gist_type" value="public">
72 <input type="radio" id="public_gist" name="gist_type" value="public" onchange="setGistId('public')">
73 73 <label for="public_gist">${_('Public Gist')}</label>
74 74 <span class="tooltip label" title="${_('Public Gists are accessible to anyone and listed in Gists page.')}">${_('Public Gist')}</span>
75 75 </div>
76 76 </fieldset>
77 77 </div>
78 78 </div>
79 79
80 80 </div>
81 81 ${h.end_form()}
82 82 </div>
83 83 </div>
84 84
85 85 </div>
86 86
87 87 <script type="text/javascript">
88 88 var myCodeMirror = initCodeMirror('editor', '');
89 89
90 90 var modes_select = $('#mimetype');
91 91 fillCodeMirrorOptions(modes_select);
92 92
93 93 var filename_selector = '#filename';
94 94 // on change of select field set mode
95 95 setCodeMirrorModeFromSelect(
96 96 modes_select, filename_selector, myCodeMirror, null);
97 97
98 98 // on entering the new filename set mode, from given extension
99 99 setCodeMirrorModeFromInput(
100 100 modes_select, filename_selector, myCodeMirror, null);
101 101
102 setGistId = function(gistType) {
103 if (gistType === 'private') {
104 $('#gistid').removeAttr('disabled');
105 }
106 else {
107 $('#gistid').val('');
108 $('#gistid').attr('disabled', 'disabled')
109 }
110 }
102 111 </script>
103 112 </%def>
General Comments 1
Under Review
author

Auto status change to "Under Review"

You need to be logged in to leave comments. Login now