Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheditor.html
More file actions
Latest commit
343 lines (316 loc) · 13.3 KB
/
Copy patheditor.html
File metadata and controls
343 lines (316 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<!doctype html>
<!-- https://github.com/paulirish/html5-boilerplate/blob/master/index.html -->
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
<!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><htmllang="en" class="no-js"><!--<![endif]-->
<head>
<!-- meta element for compatibility mode needs to be before
all elements except title & meta
msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx -->
<metacharset="utf-8">
<!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
Remove this if you use the .htaccess -->
<metahttp-equiv="X-UA-Compatible" content="IE=edge">
<title>Pythonjobs online submission editor</title>
<metaname="description" content="The pythonjobs editor page">
<!-- Because we have responsive styles, don't set device-width which makes rotation look weird
and allow users to zoom-in/out as they wish -->
<metaname="viewport" content="initial-scale=1">
<linkrel="shortcut icon" href="/favicon.ico">
<linkrel="apple-touch-icon" href="/touch-icon-iphone.png">
<linkrel="apple-touch-icon" sizes="76x76" href="/touch-icon-ipad.png">
<linkrel="apple-touch-icon" sizes="120x120" href="/touch-icon-iphone-retina.png">
<linkrel="apple-touch-icon" sizes="152x152" href="/touch-icon-ipad-retina.png">
<linkrel="apple-touch-icon" sizes="180x180" href="/touch-icon-iphone6.png">
<linkhref="/atom.xml" type="application/atom+xml" rel="alternate" title="The Free Python Job Board's atom feed" />
<linkrel="sitemap" type="application/xml" title="Sitemap" href="/sitemap.xml"/>
<linkhref='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700,400italic' rel='stylesheet' type='text/css'>
<linkrel="stylesheet" href="/media/css/font.css">
<linkrel="stylesheet" href="/media/css/site.css">
<linkhref="//fonts.googleapis.com/css?family=Source+Code+Pro:400,700" rel="stylesheet">
<linkrel="stylesheet" href="/media/css/editor.css">
</head>
<bodyid="editor">
<header>
<divclass="in">
<divid="logo"><ahref="/"><iclass="i-pyjobslogo"></i></a></div>
<divid="title"><ahref="/">The Free <span>Python Job Board</span></a></div>
<divclass="sub">for the global Python community</div>
</div>
</header>
<divid="container">
<divid=editor-column>
<h2>Editor</h2>
<divclass=infopanel>
<p>Fill in the template below. The preview should auto-update to reflect changes.</p>
<p><em><b>Please note:</b> The preview may not be 100% identical to the final output,
we use a different rendering engine for the live site.</em></p>
<p>Once you're happy with the result, press 'Create pull request' below.<br/>
<em>It helps if you're logged into github already before clicking that button (bug with github).</em><br/>
If the button doesn't work, please copy-paste the <b>editor</b> text as a new file in a Github pull request here:
<atarget=_blankhref="https://github.com/pythonjobs/jobs/new/master/jobs?filename=.html&value=paste%20here...">https://github.com/pythonjobs/jobs/new/master/jobs</a>
</p>
</div>
<divid=editor-buttons>
<buttononclick=reset_saved()>Reset to template</button>
<aid=pr-linktarget=_blank>Create Pull Request</a>
</div>
<divid=editors>
<textareaid=ad-editor>---
title: # Job Advert Title (required)
company: # Your Company (required)
url: https://... #<Linktoyoursite/a job spec (optional)>
location: # where is the job based? e.g. London,England
# Choose one of the following options
contract: # permanent / contract / part-time / temporary
contact:
name: # Your name (required)
email: # Email address applicants should submit to (required)
phone: # Phone number (optional)
# <additionalcontactfields>: <additionalvalue>
created: !!timestamp 2018-04-25
tags:
- python
- sql
- django
# include relevant tags
---
# Title
More information about the role...
## Sub-title
Further info</textarea>
</div>
</div>
<divid=preview-column>
<h2>Preview</h2>
<divid=preview></div>
</div>
</div><!--! end of #container -->
<footer>
<aclass="about" href="https://www.github.com/pythonjobs/jobs">
Have a job to advertise? Create a pull-request <iclass="i-github"></i>
</a>
The Free Python Job Board - Hosted by
<ahref="https://www.github.com/pythonjobs/jobs" target="_blank">github</a>, generated with <ahref="http://hyde.github.io/">hyde</a>.
</footer>
<!-- Javascript at the bottom for fast page loading -->
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<scriptsrc="//ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.js"></script>
<script>window.jQuery||document.write('<script src="/media/js/libs/jquery-1.5.1.min.js">\x3C/script>')</script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/showdown/1.8.6/showdown.min.js"></script>
<!-- CodeMirror -->
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/codemirror.min.js"></script>
<linkrel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/codemirror.min.css">
<!-- CodeMirror: Addons -->
<linkrel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/addon/lint/lint.min.css">
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/addon/lint/lint.min.js"></script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/js-yaml/3.11.0/js-yaml.min.js"></script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/addon/mode/overlay.min.js"></script>
<!-- CodeMirror: Modes -->
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/mode/markdown/markdown.min.js"></script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/mode/gfm/gfm.min.js"></script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/mode/yaml/yaml.min.js"></script>
<scriptsrc="//cdnjs.cloudflare.com/ajax/libs/codemirror/5.37.0/mode/yaml-frontmatter/yaml-frontmatter.min.js"></script>
<!-- Template for preview -->
<scriptsrc="//mozilla.github.io/nunjucks/files/nunjucks-slim.js"></script>
<scriptsrc="//unpkg.com/dayjs@1.5.12/dist/dayjs.min.js"></script>
<scriptsrc="/media/js/job-preview.js"></script>
<script>
'use strict';
if(!String.prototype.padStart){
String.prototype.padStart=functionpadStart(targetLength,padString){
targetLength=targetLength>>0;//truncate if number or convert non-number to 0;
padString=String((typeofpadString!=='undefined' ? padString : ' '));
if(this.length>targetLength){
returnString(this);
}
else{
targetLength=targetLength-this.length;
if(targetLength>padString.length){
padString+=padString.repeat(targetLength/padString.length);//append to original to ensure we are longer than needed
}
returnpadString.slice(0,targetLength)+String(this);
}
};
}
if(!Array.prototype.find){
Object.defineProperty(Array.prototype,'find',{
value: function(predicate){
consto=Object(this);
constlen=o.length>>>0;
letk=0;
while(k<len){
varkValue=o[k];
if(predicate(kValue)){
returnkValue;
}
k++;
}
returnundefined;
},
configurable: false,
writable: false
});
}
functionget_ad_parts(text){
letparts=(('\n'+text).split("\n---\n"));
return{meta: parts[1],body: parts[2]};
};
functionmeta_checks(full_text,errors,meta){
consttext_lines=full_text.split('\n');
constloc=CodeMirror.Pos(0,0);
functioncheck(pass,line_finder,msg){
if(!pass){
leterror_loc=loc;
for(letline=0;line<text_lines.length;++line){
if(text_lines[line].match(line_finder)){
error_loc=CodeMirror.Pos(line+1,0);
}
}
errors.push({from: error_loc,to: error_loc,message: msg});
}
}
check((meta.title||'').length>2,/^\s*title:/,"title must be provided");
check((meta.company||'').length>1,/^\s*company:/,"company must be provided");
check((meta.location||'').length>2,/^\s*location:/,"location must be provided");
check(meta.contact,"contact","Must provide contact info");
meta.contact=meta.contact||{};
check((meta.contact.name||'').length>2,/^\s*name:/,"contact.name must be provided");
check(
(meta.contact.email||'').match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,10}$/i),
/^\s*email:/,
"valid contact.email must be provided")
check(
(meta.contract||'').match(/(contract|perm|temp|part\-time|other)/i),
/^\s*contract:/,
"contract must be one of contract, perm, temp, part-time or other"
);
check(meta.created||meta.created.getFullYear,/^\s*created:/,"created must be provided and be a valid date");
check(meta.created<newDate(),/^\s*created:/,"created date must not be in the future");
check(!(meta.tags||[]).find(function(x){return(x||'').match(/index/i);}),/^\s*tags:/,"Tags cannot contain index");
}
functionfrontmatter_lint(text){
constbeginning=CodeMirror.Pos(0,0);
varfound=[];
if(!text.match(/^---\n/)){
found.push({from: beginning,to: beginning,message: "Must start with '---' on first line"});
}
constparts=get_ad_parts(text);
letmeta;
try{
meta=jsyaml.load(parts.meta);
}catch(e){
varloc=e.mark,
// Offset by 1 because of leading '---' line
from=loc ? CodeMirror.Pos(loc.line+1,loc.column) : CodeMirror.Pos(1,0),
to=from;
found.push({from: from,to: to,message: e.message});
}
if(!parts.body){
found.push({from: beginning,to: beginning,message: "Format should be:\n---\nyaml header\n---\nmarkdown body"});
}
if(meta&&meta!='undefined'){
meta_checks(parts.meta,found,meta);
}
returnfound;
}
functionreset_saved(){
window.localStorage.currentJobEditorText=''
window.location.reload(true);
}
$("#pr-link").click(function(e){
constfull_text=window.meta_codemirror.getValue();
if(frontmatter_lint(full_text).length){
if(!confirm("There are errors in this document, really continue?")){
e.preventDefault();
e.stopPropagation();
returnfalse;
}
}
});
functioniso_date(){
consttoday=newDate();
constmonth_str=(''+(today.getMonth()+1)).padStart(2,'0');
constday_str=(''+today.getDate()).padStart(2,'0');
return''+today.getFullYear()+'-'+month_str+'-'+day_str;
}
functionslugify(text)
{
returntext.toString().toLowerCase()
.replace(/\s+/g,'-')// Replace spaces with -
.replace(/[^\w\-]+/g,'')// Remove all non-word chars
.replace(/\-\-+/g,'-')// Replace multiple - with single -
.replace(/^-+/,'')// Trim - from start of text
.replace(/-+$/,'');// Trim - from end of text
}
letcur_update_id=null;
functionqueue_preview_update(){
window.localStorage.currentJobEditorText=window.meta_codemirror.getValue();
if(cur_update_id){
window.clearTimeout(cur_update_id);
cur_update_id=null;
}
cur_update_id=window.setTimeout(update_preview,200);
}
functionupdate_pr_link(full_text,meta){
constbase="https://github.com/pythonjobs/jobs/new/master/?";
constfilename='jobs/'+slugify(''+meta.company+' '+meta.title)+".html";
constquery_params=$.param({filename: filename,value: full_text});
$("#pr-link").attr('href',base+query_params);
};
functionupdate_preview(){
$("#preview").html("loading");
constfull_text=window.meta_codemirror.getValue();
try{
letparts=get_ad_parts(full_text);
parts.meta=jsyaml.load(parts.meta);
letc=dayjs(parts.meta.created);
parts.meta.created={strftime: function(){returnc.format("dddd, D MMMM YYYY");}};
letmd_converter=newshowdown.Converter({noHeaderId: true});
constdetail=md_converter.makeHtml(parts.body);
varhtml=nunjucks.render("job.j2",{
content_url: function(){return'';},
resource: parts,
detail: detail
});
$("#preview").html(html);
update_pr_link(full_text,parts.meta);
}catch(e){
console.log(e);
$("#preview").html("<b>Error generating preview</b>");
return;
}
}
$(function(){
constad_editor=document.getElementById("ad-editor");
ad_editor.value=ad_editor.value.replace(
/!!timestamp'XXX'/,
"!!timestamp "+iso_date()
);
window.meta_codemirror=CodeMirror.fromTextArea(ad_editor,{
mode: 'yaml-frontmatter',
lineWrapping: true,
lineNumbers: true,
lint: {getAnnotations: frontmatter_lint},
gutters: ["CodeMirror-lint-markers"],
viewportMargin: Infinity
});
window.meta_codemirror.on('changes',queue_preview_update);
if(localStorage.currentJobEditorText){
window.meta_codemirror.setValue(localStorage.currentJobEditorText);
}
update_preview()
});
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*newDate();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create','UA-59980478-1','auto');
ga('send','pageview');
</script>
</body>
</html>