Show More
@@ -94,10 +94,11 b' class GistsController(BaseController):' | |||||
94 | try: |
|
94 | try: | |
95 | form_result = gist_form.to_python(dict(request.POST)) |
|
95 | form_result = gist_form.to_python(dict(request.POST)) | |
96 | #TODO: multiple files support, from the form |
|
96 | #TODO: multiple files support, from the form | |
|
97 | filename = form_result['filename'] or 'gistfile1.txt' | |||
97 | nodes = { |
|
98 | nodes = { | |
98 |
|
|
99 | filename: { | |
99 | 'content': form_result['content'], |
|
100 | 'content': form_result['content'], | |
100 |
'lexer': |
|
101 | 'lexer': form_result['mimetype'] # None is autodetect | |
101 | } |
|
102 | } | |
102 | } |
|
103 | } | |
103 | _public = form_result['public'] |
|
104 | _public = form_result['public'] |
@@ -431,6 +431,7 b' def GistForm(lifetime_options):' | |||||
431 | v.UnicodeString(strip=True, required=False)) |
|
431 | v.UnicodeString(strip=True, required=False)) | |
432 | description = v.UnicodeString(required=False, if_missing='') |
|
432 | description = v.UnicodeString(required=False, if_missing='') | |
433 | lifetime = v.OneOf(lifetime_options) |
|
433 | lifetime = v.OneOf(lifetime_options) | |
|
434 | mimetype = v.UnicodeString(required=False, if_missing=None) | |||
434 | content = v.UnicodeString(required=True, not_empty=True) |
|
435 | content = v.UnicodeString(required=True, not_empty=True) | |
435 | public = v.UnicodeString(required=False, if_missing='') |
|
436 | public = v.UnicodeString(required=False, if_missing='') | |
436 | private = v.UnicodeString(required=False, if_missing='') |
|
437 | private = v.UnicodeString(required=False, if_missing='') |
@@ -16,7 +16,6 b' CodeMirror.modeInfo = [' | |||||
16 | {name: 'ECL', mime: 'text/x-ecl', mode: 'ecl'}, |
|
16 | {name: 'ECL', mime: 'text/x-ecl', mode: 'ecl'}, | |
17 | {name: 'Erlang', mime: 'text/x-erlang', mode: 'erlang'}, |
|
17 | {name: 'Erlang', mime: 'text/x-erlang', mode: 'erlang'}, | |
18 | {name: 'Gas', mime: 'text/x-gas', mode: 'gas'}, |
|
18 | {name: 'Gas', mime: 'text/x-gas', mode: 'gas'}, | |
19 | {name: 'GitHub Flavored Markdown', mode: 'gfm'}, |
|
|||
20 | {name: 'GO', mime: 'text/x-go', mode: 'go'}, |
|
19 | {name: 'GO', mime: 'text/x-go', mode: 'go'}, | |
21 | {name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy'}, |
|
20 | {name: 'Groovy', mime: 'text/x-groovy', mode: 'groovy'}, | |
22 | {name: 'Haskell', mime: 'text/x-haskell', mode: 'haskell'}, |
|
21 | {name: 'Haskell', mime: 'text/x-haskell', mode: 'haskell'}, | |
@@ -75,3 +74,232 b' CodeMirror.modeInfo = [' | |||||
75 | {name: 'YAML', mime: 'text/x-yaml', mode: 'yaml'}, |
|
74 | {name: 'YAML', mime: 'text/x-yaml', mode: 'yaml'}, | |
76 | {name: 'Z80', mime: 'text/x-z80', mode: 'z80'} |
|
75 | {name: 'Z80', mime: 'text/x-z80', mode: 'z80'} | |
77 | ]; |
|
76 | ]; | |
|
77 | ||||
|
78 | ||||
|
79 | MIME_TO_EXT = { | |||
|
80 | 'application/javascript': ['*.js'], | |||
|
81 | 'text/javascript': ['*.js'], | |||
|
82 | 'application/json': ['*.json'], | |||
|
83 | 'application/postscript': ['*.ps', '*.eps'], | |||
|
84 | 'application/x-actionscript': ['*.as'], | |||
|
85 | 'application/x-actionscript3': ['*.as'], | |||
|
86 | 'application/x-awk': ['*.awk'], | |||
|
87 | 'application/x-befunge': ['*.befunge'], | |||
|
88 | 'application/x-brainfuck': ['*.bf', '*.b'], | |||
|
89 | 'application/x-cheetah': ['*.tmpl', '*.spt'], | |||
|
90 | 'application/x-coldfusion': ['*.cfm', '*.cfml', '*.cfc'], | |||
|
91 | 'application/x-csh': ['*.tcsh', '*.csh'], | |||
|
92 | 'application/x-dos-batch': ['*.bat', '*.cmd'], | |||
|
93 | 'application/x-ecl': ['*.ecl'], | |||
|
94 | 'application/x-evoque': ['*.evoque'], | |||
|
95 | 'application/x-fantom': ['*.fan'], | |||
|
96 | 'application/x-genshi': ['*.kid'], | |||
|
97 | 'application/x-gettext': ['*.pot', '*.po'], | |||
|
98 | 'application/x-jsp': ['*.jsp'], | |||
|
99 | 'application/x-mako': ['*.mao'], | |||
|
100 | 'application/x-mason': ['*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler'], | |||
|
101 | 'application/x-myghty': ['*.myt', 'autodelegate'], | |||
|
102 | 'application/x-php': ['*.phtml'], | |||
|
103 | 'application/x-pypylog': ['*.pypylog'], | |||
|
104 | 'application/x-qml': ['*.qml'], | |||
|
105 | 'application/x-sh': ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*'], | |||
|
106 | 'application/x-sh-session': ['*.shell-session'], | |||
|
107 | 'application/x-shell-session': ['*.sh-session'], | |||
|
108 | 'application/x-smarty': ['*.tpl'], | |||
|
109 | 'application/x-ssp': ['*.ssp'], | |||
|
110 | 'application/x-troff': ['*.[1234567]', '*.man'], | |||
|
111 | 'application/x-urbiscript': ['*.u'], | |||
|
112 | 'application/xml+evoque': ['*.xml'], | |||
|
113 | 'application/xml-dtd': ['*.dtd'], | |||
|
114 | 'application/xsl+xml': ['*.xsl', '*.xslt', '*.xpl'], | |||
|
115 | 'text/S-plus': ['*.S', '*.R', '.Rhistory', '.Rprofile'], | |||
|
116 | 'text/coffeescript': ['*.coffee'], | |||
|
117 | 'text/css': ['*.css'], | |||
|
118 | 'text/haxe': ['*.hx'], | |||
|
119 | 'text/html': ['*.html', '*.htm', '*.xhtml', '*.xslt'], | |||
|
120 | 'text/html+evoque': ['*.html'], | |||
|
121 | 'text/html+ruby': ['*.rhtml'], | |||
|
122 | 'text/idl': ['*.pro'], | |||
|
123 | 'text/livescript': ['*.ls'], | |||
|
124 | 'text/matlab': ['*.m'], | |||
|
125 | 'text/octave': ['*.m'], | |||
|
126 | 'text/plain': ['*.txt'], | |||
|
127 | 'text/scilab': ['*.sci', '*.sce', '*.tst'], | |||
|
128 | 'text/smali': ['*.smali'], | |||
|
129 | 'text/x-abap': ['*.abap'], | |||
|
130 | 'text/x-ada': ['*.adb', '*.ads', '*.ada'], | |||
|
131 | 'text/x-apacheconf': ['.htaccess', 'apache.conf', 'apache2.conf'], | |||
|
132 | 'text/x-aspectj': ['*.aj'], | |||
|
133 | 'text/x-asymptote': ['*.asy'], | |||
|
134 | 'text/x-autohotkey': ['*.ahk', '*.ahkl'], | |||
|
135 | 'text/x-autoit': ['*.au3'], | |||
|
136 | 'text/x-bmx': ['*.bmx'], | |||
|
137 | 'text/x-boo': ['*.boo'], | |||
|
138 | 'text/x-c++hdr': ['*.cpp', '*.hpp', '*.c++', '*.h++', '*.cc', '*.hh', '*.cxx', '*.hxx', '*.C', '*.H', '*.cp','*.CPP'], | |||
|
139 | 'text/x-c-objdump': ['*.c-objdump'], | |||
|
140 | 'text/x-ceylon': ['*.ceylon'], | |||
|
141 | 'text/x-chdr': ['*.c', '*.h', '*.idc'], | |||
|
142 | 'text/x-clojure': ['*.clj'], | |||
|
143 | 'text/x-cmake': ['*.cmake', 'CMakeLists.txt'], | |||
|
144 | 'text/x-cobol': ['*.cob', '*.COB', '*.cpy', '*.CPY'], | |||
|
145 | 'text/x-common-lisp': ['*.cl', '*.lisp', '*.el'], | |||
|
146 | 'text/x-coq': ['*.v'], | |||
|
147 | 'text/x-cpp-objdump': ['*.cpp-objdump', '*.c++-objdump', '*.cxx-objdump'], | |||
|
148 | 'text/x-crocsrc': ['*.croc'], | |||
|
149 | 'text/x-csharp': ['*.cs'], | |||
|
150 | 'text/x-cuda': ['*.cu', '*.cuh'], | |||
|
151 | 'text/x-cython': ['*.pyx', '*.pxd', '*.pxi'], | |||
|
152 | 'text/x-d-objdump': ['*.d-objdump'], | |||
|
153 | 'text/x-dart': ['*.dart'], | |||
|
154 | 'text/x-dg': ['*.dg'], | |||
|
155 | 'text/x-diff': ['*.diff', '*.patch'], | |||
|
156 | 'text/x-dsrc': ['*.d', '*.di'], | |||
|
157 | 'text/x-duel': ['*.duel', '*.jbst'], | |||
|
158 | 'text/x-dylan': ['*.dylan', '*.dyl', '*.intr'], | |||
|
159 | 'text/x-dylan-console': ['*.dylan-console'], | |||
|
160 | 'text/x-dylan-lid': ['*.lid', '*.hdp'], | |||
|
161 | 'text/x-echdr': ['*.ec', '*.eh'], | |||
|
162 | 'text/x-elixir': ['*.ex', '*.exs'], | |||
|
163 | 'text/x-erl-shellsession': ['*.erl-sh'], | |||
|
164 | 'text/x-erlang': ['*.erl', '*.hrl', '*.es', '*.escript'], | |||
|
165 | 'text/x-factor': ['*.factor'], | |||
|
166 | 'text/x-fancysrc': ['*.fy', '*.fancypack'], | |||
|
167 | 'text/x-felix': ['*.flx', '*.flxh'], | |||
|
168 | 'text/x-fortran': ['*.f', '*.f90', '*.F', '*.F90'], | |||
|
169 | 'text/x-fsharp': ['*.fs', '*.fsi'], | |||
|
170 | 'text/x-gas': ['*.s', '*.S'], | |||
|
171 | 'text/x-gherkin': ['*.feature'], | |||
|
172 | 'text/x-glslsrc': ['*.vert', '*.frag', '*.geo'], | |||
|
173 | 'text/x-gnuplot': ['*.plot', '*.plt'], | |||
|
174 | 'text/x-gooddata-cl': ['*.gdc'], | |||
|
175 | 'text/x-gooddata-maql': ['*.maql'], | |||
|
176 | 'text/x-gosrc': ['*.go'], | |||
|
177 | 'text/x-gosu': ['*.gs', '*.gsx', '*.gsp', '*.vark'], | |||
|
178 | 'text/x-gosu-template': ['*.gst'], | |||
|
179 | 'text/x-groovy': ['*.groovy'], | |||
|
180 | 'text/x-haml': ['*.haml'], | |||
|
181 | 'text/x-haskell': ['*.hs'], | |||
|
182 | 'text/x-hybris': ['*.hy', '*.hyb'], | |||
|
183 | 'text/x-ini': ['*.ini', '*.cfg'], | |||
|
184 | 'text/x-iokesrc': ['*.ik'], | |||
|
185 | 'text/x-iosrc': ['*.io'], | |||
|
186 | 'text/x-irclog': ['*.weechatlog'], | |||
|
187 | 'text/x-jade': ['*.jade'], | |||
|
188 | 'text/x-java': ['*.java'], | |||
|
189 | 'text/x-java-properties': ['*.properties'], | |||
|
190 | 'text/x-julia': ['*.jl'], | |||
|
191 | 'text/x-kconfig': ['Kconfig', '*Config.in*', 'external.in*', 'standard-modules.in'], | |||
|
192 | 'text/x-koka': ['*.kk', '*.kki'], | |||
|
193 | 'text/x-kotlin': ['*.kt'], | |||
|
194 | 'text/x-lasso': ['*.lasso', '*.lasso[89]'], | |||
|
195 | 'text/x-literate-haskell': ['*.lhs'], | |||
|
196 | 'text/x-llvm': ['*.ll'], | |||
|
197 | 'text/x-logos': ['*.x', '*.xi', '*.xm', '*.xmi'], | |||
|
198 | 'text/x-logtalk': ['*.lgt'], | |||
|
199 | 'text/x-lua': ['*.lua', '*.wlua'], | |||
|
200 | 'text/x-makefile': ['*.mak', 'Makefile', 'makefile', 'Makefile.*', 'GNUmakefile'], | |||
|
201 | 'text/x-minidsrc': ['*.md'], | |||
|
202 | 'text/x-markdown': ['*.md'], | |||
|
203 | 'text/x-modelica': ['*.mo'], | |||
|
204 | 'text/x-modula2': ['*.def', '*.mod'], | |||
|
205 | 'text/x-monkey': ['*.monkey'], | |||
|
206 | 'text/x-moocode': ['*.moo'], | |||
|
207 | 'text/x-moonscript': ['*.moon'], | |||
|
208 | 'text/x-nasm': ['*.asm', '*.ASM'], | |||
|
209 | 'text/x-nemerle': ['*.n'], | |||
|
210 | 'text/x-newlisp': ['*.lsp', '*.nl'], | |||
|
211 | 'text/x-newspeak': ['*.ns2'], | |||
|
212 | 'text/x-nimrod': ['*.nim', '*.nimrod'], | |||
|
213 | 'text/x-nsis': ['*.nsi', '*.nsh'], | |||
|
214 | 'text/x-objdump': ['*.objdump'], | |||
|
215 | 'text/x-objective-c': ['*.m', '*.h'], | |||
|
216 | 'text/x-objective-c++': ['*.mm', '*.hh'], | |||
|
217 | 'text/x-objective-j': ['*.j'], | |||
|
218 | 'text/x-ocaml': ['*.ml', '*.mli', '*.mll', '*.mly'], | |||
|
219 | 'text/x-ooc': ['*.ooc'], | |||
|
220 | 'text/x-opa': ['*.opa'], | |||
|
221 | 'text/x-openedge': ['*.p', '*.cls'], | |||
|
222 | 'text/x-pascal': ['*.pas'], | |||
|
223 | 'text/x-perl': ['*.pl', '*.pm'], | |||
|
224 | 'text/x-php': ['*.php', '*.php[345]', '*.inc'], | |||
|
225 | 'text/x-povray': ['*.pov', '*.inc'], | |||
|
226 | 'text/x-powershell': ['*.ps1'], | |||
|
227 | 'text/x-prolog': ['*.prolog', '*.pro', '*.pl'], | |||
|
228 | 'text/x-python': ['*.py', '*.pyw', '*.sc', 'SConstruct', 'SConscript', '*.tac', '*.sage'], | |||
|
229 | 'text/x-python-traceback': ['*.pytb'], | |||
|
230 | 'text/x-python3-traceback': ['*.py3tb'], | |||
|
231 | 'text/x-r-doc': ['*.Rd'], | |||
|
232 | 'text/x-racket': ['*.rkt', '*.rktl'], | |||
|
233 | 'text/x-rebol': ['*.r', '*.r3'], | |||
|
234 | 'text/x-robotframework': ['*.txt', '*.robot'], | |||
|
235 | 'text/x-rpm-spec': ['*.spec'], | |||
|
236 | 'text/x-rst': ['*.rst', '*.rest'], | |||
|
237 | 'text/x-ruby': ['*.rb', '*.rbw', 'Rakefile', '*.rake', '*.gemspec', '*.rbx', '*.duby'], | |||
|
238 | 'text/x-rustsrc': ['*.rs', '*.rc'], | |||
|
239 | 'text/x-sass': ['*.sass'], | |||
|
240 | 'text/x-scala': ['*.scala'], | |||
|
241 | 'text/x-scaml': ['*.scaml'], | |||
|
242 | 'text/x-scheme': ['*.scm', '*.ss'], | |||
|
243 | 'text/x-scss': ['*.scss'], | |||
|
244 | 'text/x-smalltalk': ['*.st'], | |||
|
245 | 'text/x-snobol': ['*.snobol'], | |||
|
246 | 'text/x-sourcepawn': ['*.sp'], | |||
|
247 | 'text/x-sql': ['*.sql'], | |||
|
248 | 'text/x-sqlite3-console': ['*.sqlite3-console'], | |||
|
249 | 'text/x-squidconf': ['squid.conf'], | |||
|
250 | 'text/x-standardml': ['*.sml', '*.sig', '*.fun'], | |||
|
251 | 'text/x-systemverilog': ['*.sv', '*.svh'], | |||
|
252 | 'text/x-tcl': ['*.tcl'], | |||
|
253 | 'text/x-tea': ['*.tea'], | |||
|
254 | 'text/x-tex': ['*.tex', '*.aux', '*.toc'], | |||
|
255 | 'text/x-typescript': ['*.ts'], | |||
|
256 | 'text/x-vala': ['*.vala', '*.vapi'], | |||
|
257 | 'text/x-vbnet': ['*.vb', '*.bas'], | |||
|
258 | 'text/x-verilog': ['*.v'], | |||
|
259 | 'text/x-vhdl': ['*.vhdl', '*.vhd'], | |||
|
260 | 'text/x-vim': ['*.vim', '.vimrc', '.exrc', '.gvimrc', '_vimrc', '_exrc', '_gvimrc', 'vimrc', 'gvimrc'], | |||
|
261 | 'text/x-windows-registry': ['*.reg'], | |||
|
262 | 'text/x-xtend': ['*.xtend'], | |||
|
263 | 'text/x-yaml': ['*.yaml', '*.yml'], | |||
|
264 | 'text/xml': ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'], | |||
|
265 | 'text/xquery': ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'], | |||
|
266 | 'text/apl': [], | |||
|
267 | 'text/x-asterisk': [], | |||
|
268 | 'text/x-csrc': [], | |||
|
269 | 'text/x-c++src': ['*.cpp'], | |||
|
270 | 'text/x-coffeescript': ['*.coffee'], | |||
|
271 | 'text/x-d': ["*.d"], | |||
|
272 | 'text/x-ecl': ['*.ecl'], | |||
|
273 | 'text/x-go': ['*.go'], | |||
|
274 | 'text/x-haxe': ['*.hx'], | |||
|
275 | 'application/x-aspx': ['*.aspx'], | |||
|
276 | 'application/x-ejs': [], | |||
|
277 | 'message/http': [], | |||
|
278 | 'application/x-json': ['*.json'], | |||
|
279 | 'application/typescript': ['*.ts'], | |||
|
280 | 'jinja2': ['.jinja2'], | |||
|
281 | 'text/x-less': ['*.less'], | |||
|
282 | 'text/x-livescript': ['*.ls'], | |||
|
283 | 'text/mirc': [], | |||
|
284 | 'text/n-triples': [], | |||
|
285 | 'application/x-httpd-php': ['*.php'], | |||
|
286 | 'text/x-pig': [], | |||
|
287 | 'text/x-properties': ['*.properties'], | |||
|
288 | 'text/x-rsrc': [], | |||
|
289 | 'text/x-sh': ['*.sh', '*.ksh', '*.bash', '*.ebuild', '*.eclass', '.bashrc', 'bashrc', '.bash_*', 'bash_*'], | |||
|
290 | 'application/sieve': [], | |||
|
291 | 'text/x-stsrc': ['*.rs', '*.rc'], | |||
|
292 | 'text/x-smarty': ['*.tpl'], | |||
|
293 | 'application/x-sparql-query': [], | |||
|
294 | 'text/x-mariadb': ['*.sql'], | |||
|
295 | 'text/x-stex': [], | |||
|
296 | 'text/x-latex': ["*.ltx"], | |||
|
297 | 'text/x-tiddlywiki': [], | |||
|
298 | 'text/tiki': [], | |||
|
299 | 'text/x-vb': ['*.vb'], | |||
|
300 | 'text/vbscript': ['*.vb'], | |||
|
301 | 'text/velocity': [], | |||
|
302 | 'application/xml': ['*.xml', '*.xsl', '*.rss', '*.xslt', '*.xsd', '*.wsdl'], | |||
|
303 | 'application/xquery': ['*.xqy', '*.xquery', '*.xq', '*.xql', '*.xqm'], | |||
|
304 | 'text/x-z80': [], | |||
|
305 | } |
@@ -37,14 +37,17 b'' | |||||
37 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.rhodecode_user.full_contact),32)}"/> |
|
37 | <img alt="gravatar" src="${h.gravatar_url(h.email_or_none(c.rhodecode_user.full_contact),32)}"/> | |
38 | </div> |
|
38 | </div> | |
39 | <textarea style="resize:vertical; width:400px;border: 1px solid #ccc;border-radius: 3px;" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea> |
|
39 | <textarea style="resize:vertical; width:400px;border: 1px solid #ccc;border-radius: 3px;" id="description" name="description" placeholder="${_('Gist description ...')}"></textarea> | |
|
40 | <div style="padding:0px 0px 0px 42px"> | |||
|
41 | <label for='lifetime'>${_('Gist lifetime')}</label> | |||
|
42 | ${h.select('lifetime', '', c.lifetime_options)} | |||
|
43 | </div> | |||
40 | </div> |
|
44 | </div> | |
41 | <div id="body" class="codeblock"> |
|
45 | <div id="body" class="codeblock"> | |
42 | <div style="padding: 10px 10px 10px 26px;color:#666666"> |
|
46 | <div style="padding: 10px 10px 10px 26px;color:#666666"> | |
43 | ##<input type="text" value="" size="30" name="filename" id="filename" placeholder="gistfile1.txt"> |
|
47 | ##<input type="text" value="" size="30" name="filename" id="filename" placeholder="gistfile1.txt"> | |
44 | ${h.text('filename', size=30, placeholder='gistfile1.txt')} |
|
48 | ${h.text('filename', size=30, placeholder='gistfile1.txt')} | |
45 | ##<input type="text" value="" size="30" name="filename" id="filename" placeholder="gistfile1.txt"> |
|
49 | ##<input type="text" value="" size="30" name="filename" id="filename" placeholder="gistfile1.txt"> | |
46 |
${h.select(' |
|
50 | ${h.select('mimetype','plain',[('plain',_('plain'))])} | |
47 | ${h.select('set_mode','plain',[('plain',_('plain'))])} |
|
|||
48 | </div> |
|
51 | </div> | |
49 | <div id="editor_container"> |
|
52 | <div id="editor_container"> | |
50 | <pre id="editor_pre"></pre> |
|
53 | <pre id="editor_pre"></pre> | |
@@ -62,16 +65,30 b'' | |||||
62 | CodeMirror.modeURL = "${h.url('/js/mode/%N/%N.js')}"; |
|
65 | CodeMirror.modeURL = "${h.url('/js/mode/%N/%N.js')}"; | |
63 |
|
66 | |||
64 | //inject new modes |
|
67 | //inject new modes | |
65 |
var modes_select = YUD.get(' |
|
68 | var modes_select = YUD.get('mimetype'); | |
66 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ |
|
69 | for(var i=0;i<CodeMirror.modeInfo.length;i++){ | |
67 | var m = CodeMirror.modeInfo[i]; |
|
70 | var m = CodeMirror.modeInfo[i]; | |
68 |
var opt = new Option(m.name, m.m |
|
71 | var opt = new Option(m.name, m.mime); | |
69 | modes_select.options[i+1] = opt |
|
72 | YUD.setAttribute(opt, 'mode', m.mode) | |
|
73 | modes_select.options[i+1] = opt; | |||
70 | } |
|
74 | } | |
71 | YUE.on(modes_select, 'change', function(e){ |
|
75 | YUE.on(modes_select, 'change', function(e){ | |
72 | var selected = e.currentTarget; |
|
76 | var selected = e.currentTarget; | |
73 |
var n |
|
77 | var node = selected.options[selected.selectedIndex]; | |
|
78 | var mimetype = node.value; | |||
|
79 | var new_mode = YUD.getAttribute(node, 'mode') | |||
74 | setCodeMirrorMode(myCodeMirror, new_mode); |
|
80 | setCodeMirrorMode(myCodeMirror, new_mode); | |
|
81 | ||||
|
82 | var proposed_mimetypes = MIME_TO_EXT[mimetype] || []; | |||
|
83 | if(proposed_mimetypes.length < 1){ | |||
|
84 | //fallback to text/plain | |||
|
85 | proposed_mimetypes = ['.txt'] | |||
|
86 | } | |||
|
87 | var mt = proposed_mimetypes[0]; | |||
|
88 | if(mt[0] == '*'){ | |||
|
89 | mt = mt.substr(1) | |||
|
90 | } | |||
|
91 | YUD.get('filename').value = 'filename1' + mt; | |||
75 | }) |
|
92 | }) | |
76 | </script> |
|
93 | </script> | |
77 | </div> |
|
94 | </div> |
General Comments 0
You need to be logged in to leave comments.
Login now