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