Show More
@@ -1,136 +1,136 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('Edit Gist')} · ${c.gist.gist_access_id} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="breadcrumbs_links()"></%def> |
|
11 | 11 | |
|
12 | 12 | <%def name="menu_bar_nav()"> |
|
13 | 13 | ${self.menu_items(active='gists')} |
|
14 | 14 | </%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="main()"> |
|
17 | 17 | <div class="box"> |
|
18 | 18 | <!-- box / title --> |
|
19 | 19 | <div class="title"> |
|
20 | 20 | |
|
21 | 21 | </div> |
|
22 | 22 | |
|
23 | 23 | <div class="table"> |
|
24 | 24 | <div id="files_data"> |
|
25 | 25 | ${h.secure_form(h.route_path('gist_update', gist_id=c.gist.gist_access_id), id='eform', request=request)} |
|
26 | 26 | <div> |
|
27 | 27 | <input type="hidden" value="${c.file_last_commit.raw_id}" name="parent_hash"> |
|
28 | 28 | <div> |
|
29 | 29 | <span class="gist-gravatar"> |
|
30 | 30 | ${self.gravatar(h.email_or_none(c.rhodecode_user.full_contact), 30)} |
|
31 | 31 | </span> |
|
32 | 32 | <label for='lifetime'>${_('Gist lifetime')}</label> |
|
33 | 33 | ${h.dropdownmenu('lifetime', '0', c.lifetime_options)} |
|
34 | 34 | |
|
35 | 35 | <label for='gist_acl_level'>${_('Gist access level')}</label> |
|
36 | 36 | ${h.dropdownmenu('gist_acl_level', c.gist.acl_level, c.acl_options)} |
|
37 | 37 | |
|
38 | 38 | <textarea style="margin-top: 5px; border-color: #dbd9da" id="description" name="description" |
|
39 | 39 | placeholder="${_('Gist description ...')}">${c.gist.gist_description}</textarea> |
|
40 | 40 | </div> |
|
41 | 41 | </div> |
|
42 | 42 | |
|
43 | 43 | ## peppercorn schema |
|
44 | 44 | <input type="hidden" name="__start__" value="nodes:sequence"/> |
|
45 | 45 | % for cnt, file in enumerate(c.files): |
|
46 | 46 | <input type="hidden" name="__start__" value="file:mapping"/> |
|
47 | 47 | <div id="codeblock" class="codeblock" > |
|
48 | 48 | <div class="code-header"> |
|
49 | 49 | <div class="form"> |
|
50 | 50 | <div class="fields"> |
|
51 | 51 | <input type="hidden" name="filename_org" value="${file.path}" > |
|
52 | 52 | <input id="filename_${h.FID('f',file.path)}" name="filename" size="30" type="text" value="${file.path}"> |
|
53 | 53 | ${h.dropdownmenu('mimetype' ,'plain',[('plain',_('plain'))],enable_filter=True, id='mimetype_'+h.FID('f',file.path))} |
|
54 | 54 | </div> |
|
55 | 55 | </div> |
|
56 | 56 | </div> |
|
57 | 57 | <div class="editor_container"> |
|
58 | 58 | <pre id="editor_pre"></pre> |
|
59 | <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.content}</textarea> | |
|
59 | <textarea id="editor_${h.FID('f',file.path)}" name="content" >${file.str_content}</textarea> | |
|
60 | 60 | </div> |
|
61 | 61 | </div> |
|
62 | 62 | <input type="hidden" name="__end__" /> |
|
63 | 63 | |
|
64 | 64 | ## dynamic edit box. |
|
65 | 65 | <script type="text/javascript"> |
|
66 | 66 | $(document).ready(function(){ |
|
67 | 67 | var myCodeMirror = initCodeMirror( |
|
68 | 68 | "editor_${h.FID('f',file.path)}", ''); |
|
69 | 69 | |
|
70 | 70 | var modes_select = $("#mimetype_${h.FID('f',file.path)}"); |
|
71 | 71 | fillCodeMirrorOptions(modes_select); |
|
72 | 72 | |
|
73 | 73 | // try to detect the mode based on the file we edit |
|
74 | 74 | var mimetype = "${file.mimetype}"; |
|
75 | 75 | var detected_mode = detectCodeMirrorMode( |
|
76 | 76 | "${file.path}", mimetype); |
|
77 | 77 | |
|
78 | 78 | if(detected_mode){ |
|
79 | 79 | $(modes_select).select2("val", mimetype); |
|
80 | 80 | $(modes_select).change(); |
|
81 | 81 | setCodeMirrorMode(myCodeMirror, detected_mode); |
|
82 | 82 | } |
|
83 | 83 | |
|
84 | 84 | var filename_selector = "#filename_${h.FID('f',file.path)}"; |
|
85 | 85 | // on change of select field set mode |
|
86 | 86 | setCodeMirrorModeFromSelect( |
|
87 | 87 | modes_select, filename_selector, myCodeMirror, null); |
|
88 | 88 | |
|
89 | 89 | // on entering the new filename set mode, from given extension |
|
90 | 90 | setCodeMirrorModeFromInput( |
|
91 | 91 | modes_select, filename_selector, myCodeMirror, null); |
|
92 | 92 | }); |
|
93 | 93 | </script> |
|
94 | 94 | %endfor |
|
95 | 95 | <input type="hidden" name="__end__" /> |
|
96 | 96 | |
|
97 | 97 | <div class="pull-left"> |
|
98 | 98 | ${h.submit('update',_('Update Gist'),class_="btn btn-success")} |
|
99 | 99 | <a class="btn" href="${h.route_path('gist_show', gist_id=c.gist.gist_access_id)}">${_('Cancel')}</a> |
|
100 | 100 | </div> |
|
101 | 101 | ${h.end_form()} |
|
102 | 102 | </div> |
|
103 | 103 | </div> |
|
104 | 104 | |
|
105 | 105 | </div> |
|
106 | 106 | <script> |
|
107 | 107 | $('#update').on('click', function(e){ |
|
108 | 108 | e.preventDefault(); |
|
109 | 109 | |
|
110 | 110 | $(this).val('Updating...'); |
|
111 | 111 | $(this).attr('disabled', 'disabled'); |
|
112 | 112 | // check for newer version. |
|
113 | 113 | $.ajax({ |
|
114 | 114 | url: "${h.route_path('gist_edit_check_revision', gist_id=c.gist.gist_access_id)}", |
|
115 | 115 | data: { |
|
116 | 116 | 'revision': '${c.file_last_commit.raw_id}' |
|
117 | 117 | }, |
|
118 | 118 | dataType: 'json', |
|
119 | 119 | type: 'GET', |
|
120 | 120 | success: function(data) { |
|
121 | 121 | if(data.success === false){ |
|
122 | 122 | message = '${h.literal(_('Gist was updated since you started editing. Copy your changes and click %(here)s to reload the new version.') |
|
123 | 123 | % {'here': h.link_to('here', h.route_path('gist_edit', gist_id=c.gist.gist_access_id))})}' |
|
124 | 124 | alertMessage = [{"message": { |
|
125 | 125 | "message": message, "force": "true", "level": "warning"}}]; |
|
126 | 126 | $.Topic('/notifications').publish(alertMessage[0]); |
|
127 | 127 | } |
|
128 | 128 | else{ |
|
129 | 129 | $('#eform').submit(); |
|
130 | 130 | } |
|
131 | 131 | } |
|
132 | 132 | }); |
|
133 | 133 | }) |
|
134 | 134 | |
|
135 | 135 | </script> |
|
136 | 136 | </%def> |
@@ -1,112 +1,112 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | <%namespace name="dt" file="/data_table/_dt_elements.mako"/> |
|
3 | 3 | |
|
4 | 4 | <%def name="robots()"> |
|
5 | 5 | %if c.gist.gist_type != 'public': |
|
6 | 6 | <meta name="robots" content="noindex, nofollow"> |
|
7 | 7 | %else: |
|
8 | 8 | ${parent.robots()} |
|
9 | 9 | %endif |
|
10 | 10 | </%def> |
|
11 | 11 | |
|
12 | 12 | <%def name="title()"> |
|
13 | 13 | ${_('Gist')} · ${c.gist.gist_access_id} |
|
14 | 14 | %if c.rhodecode_name: |
|
15 | 15 | · ${h.branding(c.rhodecode_name)} |
|
16 | 16 | %endif |
|
17 | 17 | </%def> |
|
18 | 18 | |
|
19 | 19 | <%def name="breadcrumbs_links()"> |
|
20 | 20 | ${_('Gist')} · ${c.gist.gist_access_id} |
|
21 | 21 | </%def> |
|
22 | 22 | |
|
23 | 23 | <%def name="menu_bar_nav()"> |
|
24 | 24 | ${self.menu_items(active='gists')} |
|
25 | 25 | </%def> |
|
26 | 26 | |
|
27 | 27 | <%def name="main()"> |
|
28 | 28 | <div class="box"> |
|
29 | 29 | <!-- box / title --> |
|
30 | 30 | |
|
31 | 31 | <div class="table"> |
|
32 | 32 | <div id="files_data"> |
|
33 | 33 | <div id="codeblock" class="codeblock"> |
|
34 | 34 | <div class="code-header"> |
|
35 | 35 | <div class="gist_url"> |
|
36 | 36 | <div class="pull-left"> |
|
37 | 37 | <code> |
|
38 | 38 | ${dt.gist_type(c.gist.gist_type)} |
|
39 | 39 | <span class="tag disabled">${c.gist.gist_access_id}</span> |
|
40 | 40 | ${c.gist.gist_url()} <span class="icon-clipboard clipboard-action" data-clipboard-text="${c.gist.gist_url()}" title="${_('Copy the url')}"></span> |
|
41 | 41 | </code> |
|
42 | 42 | </div> |
|
43 | 43 | |
|
44 | 44 | <div class="pull-right buttons"> |
|
45 | 45 | ## only owner should see that |
|
46 | <a href="#copySource" onclick="return false;" class="btn btn-mini icon-clipboard no-grey clipboard-action" data-clipboard-text="${c.files[0].content}">${_('Copy content')}</a> | |
|
46 | <a href="#copySource" onclick="return false;" class="btn btn-mini icon-clipboard no-grey clipboard-action" data-clipboard-text="${c.files[0].str_content}">${_('Copy content')}</a> | |
|
47 | 47 | |
|
48 | 48 | %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id: |
|
49 | 49 | ${h.link_to(_('Edit'), h.route_path('gist_edit', gist_id=c.gist.gist_access_id), class_="btn btn-mini")} |
|
50 | 50 | %endif |
|
51 | 51 | ${h.link_to(_('Show as Raw'), h.route_path('gist_show_formatted', gist_id=c.gist.gist_access_id, revision='tip', format='raw'), class_="btn btn-mini")} |
|
52 | 52 | |
|
53 | 53 | %if c.is_super_admin or c.gist.gist_owner == c.rhodecode_user.user_id: |
|
54 | 54 | <div class="pull-right remove_gist"> |
|
55 | 55 | ${h.secure_form(h.route_path('gist_delete', gist_id=c.gist.gist_access_id), request=request)} |
|
56 | 56 | <input class="btn btn-mini btn-danger" id="remove_gist" name="remove_gist" |
|
57 | 57 | onclick="submitConfirm(event, this, _gettext('Confirm to delete this gist'), _gettext('Delete'), '${c.gist.gist_access_id}')" |
|
58 | 58 | type="submit" value="${_('Delete')}" |
|
59 | 59 | > |
|
60 | 60 | ${h.end_form()} |
|
61 | 61 | </div> |
|
62 | 62 | %endif |
|
63 | 63 | </div> |
|
64 | 64 | </div> |
|
65 | 65 | |
|
66 | 66 | <div class="gist-desc"> |
|
67 | 67 | <code>${c.gist.gist_description}</code> |
|
68 | 68 | </div> |
|
69 | 69 | |
|
70 | 70 | <div class="author"> |
|
71 | 71 | <div title="${h.tooltip(c.file_last_commit.author)}"> |
|
72 | 72 | ${self.gravatar_with_user(c.file_last_commit.author, 16, tooltip=True)} - ${_('created')} ${h.age_component(c.file_last_commit.date)}, |
|
73 | 73 | ${_('expires')}: |
|
74 | 74 | %if c.gist.gist_expires == -1: |
|
75 | 75 | ${_('never')} |
|
76 | 76 | %else: |
|
77 | 77 | ${h.age_component(h.time_to_utcdatetime(c.gist.gist_expires))} |
|
78 | 78 | %endif |
|
79 | 79 | </span> |
|
80 | 80 | </div> |
|
81 | 81 | |
|
82 | 82 | </div> |
|
83 | 83 | <div class="commit">${h.urlify_commit_message(c.file_last_commit.message, None)}</div> |
|
84 | 84 | </div> |
|
85 | 85 | |
|
86 | 86 | ## iterate over the files |
|
87 | 87 | % for gist_file in c.files: |
|
88 | 88 | <% renderer = c.render and h.renderer_from_filename(gist_file.path, exclude=['.txt', '.TXT'])%> |
|
89 | 89 | <!-- |
|
90 | 90 | <div id="${h.FID('G', gist_file.path)}" class="stats" > |
|
91 | 91 | <a href="${c.gist.gist_url()}">¶</a> |
|
92 | 92 | <b >${gist_file.path}</b> |
|
93 | 93 | <div> |
|
94 | 94 | ${h.link_to(_('Show as raw'), h.route_path('gist_show_formatted_path', gist_id=c.gist.gist_access_id, revision=gist_file.commit.raw_id, format='raw', f_path=gist_file.path), class_="btn btn-mini")} |
|
95 | 95 | </div> |
|
96 | 96 | </div> |
|
97 | 97 | --> |
|
98 | 98 | <div class="code-body textarea text-area editor"> |
|
99 | 99 | %if renderer: |
|
100 | 100 | ${h.render(gist_file.str_content, renderer=renderer)} |
|
101 | 101 | %else: |
|
102 | 102 | ${h.pygmentize(gist_file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} |
|
103 | 103 | %endif |
|
104 | 104 | </div> |
|
105 | 105 | %endfor |
|
106 | 106 | </div> |
|
107 | 107 | </div> |
|
108 | 108 | </div> |
|
109 | 109 | |
|
110 | 110 | |
|
111 | 111 | </div> |
|
112 | 112 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now