/
bundle.js
7529 lines (6422 loc) · 235 KB
/
bundle.js
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var config = {
development: {
client_id: '3399f4b75617c8ca5876',
redirect_uri: 'http://127.0.0.1:9966',
proxy: 'http://127.0.0.1:5000',
scope: 'repo',
github: {
owner: 'editdata',
repo: 'submit-data',
branch: 'gh-pages'
},
site: {
title: 'Submit Data',
description: 'Submit a row to a csv/json file in a GitHub repo',
slug: 'submit-data-dev-site',
data: 'data.json'
}
},
production: {
client_id: 'e726b293f8f60b2e7170',
redirect_uri: 'http://submitdata.surge.sh',
proxy: 'https://submit-data-demo.herokuapp.com',
scope: 'repo',
github: {
owner: 'editdata',
repo: 'submit-data',
branch: 'gh-pages'
},
site: {
title: 'Submit Data',
description: 'Submit a row to a csv/json file in a GitHub repo',
slug: 'submit-data-demo-site',
data: 'data.json'
}
}
}
var env = "production" || 'development'
module.exports = config[env]
},{}],2:[function(require,module,exports){
module.exports=[
{
"title": "example",
"description": "This is an example.",
"url": "http://example.com"
}
]
},{}],3:[function(require,module,exports){
var el = require('yo-yo')
module.exports = function githubAuth (config, actions) {
var url = 'https://github.com/login/oauth/authorize' +
'?client_id=' + config.client_id +
'&scope=' + config.scope +
'&redirect_uri=' + config.redirect_uri
function login (state) {
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel0 = document.createElement("a")
bel0.setAttribute("href", arguments[0])
bel0.setAttribute("class", "profile-login button")
appendChild(bel0, ["Sign in with GitHub"])
return bel0
}(url))
}
function profile (state) {
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel4 = document.createElement("div")
bel4.setAttribute("class", "profile")
var bel2 = document.createElement("a")
bel2.setAttribute("href", arguments[2])
bel2.setAttribute("target", "_blank")
bel2.setAttribute("class", "button")
var bel0 = document.createElement("img")
bel0.setAttribute("src", arguments[0])
bel0.setAttribute("class", "profile-avatar")
var bel1 = document.createElement("span")
bel1.setAttribute("class", "profile-name")
appendChild(bel1, [arguments[1]])
appendChild(bel2, ["\n ",bel0,"\n ",bel1,"\n "])
var bel3 = document.createElement("a")
bel3.setAttribute("href", "#")
bel3["onclick"] = arguments[3]
bel3.setAttribute("class", "profile-logout button")
appendChild(bel3, ["\n Sign out\n "])
appendChild(bel4, ["\n ",bel2,"\n ",bel3,"\n "])
return bel4
}(state.user.profile.avatar_url,state.user.profile.name,state.user.profile.html_url,actions.onLogOut))
}
function childElement (state) {
if (state.user) return profile(state)
else return login(state)
}
return {
render: function virtualGithubAuth_render (state) {
var className = 'github-auth'
if (state.user) className += ' active'
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel0 = document.createElement("div")
bel0.setAttribute("class", arguments[0])
appendChild(bel0, [arguments[1]])
return bel0
}(className,childElement(state)))
}
}
}
},{"yo-yo":46}],4:[function(require,module,exports){
var defaults = require('json-schema-defaults')
var el = require('yo-yo')
var schema = require('./schema')
module.exports = function renderForm (state, actions) {
var obj = defaults(schema)
var keys = Object.keys(obj)
function field (key) {
var value = obj[key] ? obj[key] : ''
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel2 = document.createElement("div")
bel2.setAttribute("class", "field")
var bel0 = document.createElement("label")
bel0.setAttribute("htmlFor", arguments[0])
appendChild(bel0, [arguments[1]])
var bel1 = document.createElement("input")
bel1.setAttribute("name", arguments[2])
bel1.setAttribute("type", "text")
bel1.setAttribute("value", arguments[3])
bel1.setAttribute("class", "field-text")
appendChild(bel1, ["\n "])
appendChild(bel2, ["\n ",bel0,"\n ",bel1,"\n "])
return bel2
}(key,key,key,value))
}
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel3 = document.createElement("div")
bel3.setAttribute("class", "form")
var bel0 = document.createElement("p")
appendChild(bel0, ["This site will create a fork of this repo on your account, create a branch for your submission, save your submission, then create a pull request on the source repository."])
var bel2 = document.createElement("form")
bel2["onsubmit"] = arguments[0]
var bel1 = document.createElement("input")
bel1.setAttribute("type", "submit")
bel1.setAttribute("value", "Save item")
bel1.setAttribute("class", "button")
appendChild(bel2, ["\n ",arguments[1],"\n ",bel1,"\n "])
appendChild(bel3, ["\n ",bel0,"\n ",bel2,"\n "])
return bel3
}(actions.onsubmit,keys.map(field)))
}
},{"./schema":48,"json-schema-defaults":31,"yo-yo":46}],5:[function(require,module,exports){
var request = require('xhr')
module.exports = function getBlob (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/contents/' + options.path,
headers: { authorization: 'token ' + options.token },
json: {
ref: options.ref
}
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
var content = window.atob(body.content)
callback(err, body, JSON.parse(content))
})
}
},{"xhr":43}],6:[function(require,module,exports){
var request = require('xhr')
var base64 = require('base-64')
var utf8 = require('utf8')
module.exports = function updateBlob (options, callback) {
var opts = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/contents/' + options.path,
headers: { authorization: 'token ' + options.token },
method: 'put',
json: {
path: options.path,
message: options.message,
content: base64.encode(utf8.encode(options.content)),
branch: options.branch,
sha: options.sha
}
}
request(opts, function (err, res, body) {
if (err) return callback(err)
var save = {
branch: options.branch,
owner: options.owner,
repo: options.repo,
location: body.content,
source: 'github'
}
callback(null, body, save)
})
}
},{"base-64":17,"utf8":42,"xhr":43}],7:[function(require,module,exports){
var request = require('xhr')
var moment = require('moment')
module.exports = function createBranch (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/git/refs',
headers: { authorization: 'token ' + options.token },
method: 'POST',
json: {
ref: 'refs/heads/submit-data-' + moment().format('MMM-Do-YY-h-mm-ss'),
sha: options.commit.sha
}
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
callback(err, body)
})
}
},{"moment":33,"xhr":43}],8:[function(require,module,exports){
var request = require('xhr')
module.exports = function fork (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/forks',
headers: { authorization: 'token ' + options.token },
method: 'POST',
json: true
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
// var content = window.atob(body.content)
callback(err, body)
})
}
},{"xhr":43}],9:[function(require,module,exports){
var request = require('xhr')
var list = require('./fork-list')
var createFork = require('./fork-create')
var createBranch = require('./branch-create')
var getCommit = require('./latest-commit')
/**
* Creates a fork on the user's account if needed.
* Creates a branch if fork already exists, or after the fork was created.
*/
module.exports = function forkAndBranch (options, callback) {
getCommit(options, function (err, commit) {
options.commit = commit
list(options, findFork)
})
function findFork (err, forks) {
if (err) return callback(err)
var fork = forks.filter(function (f) {
return f.owner.login === options.user
})
if (fork && fork[0]) {
fork = fork[0]
createBranch({
github: { owner: options.user, repo: options.github.repo },
commit: options.commit,
token: options.token
}, function (err, res) {
if (err) return callback(err)
callback(null, fork, res)
})
} else {
createFork(options, function (err, forkResponse) {
if (err) return callback(err)
fork = forkResponse
createBranch({
github: { owner: fork.owner.login, repo: options.github.repo },
commit: options.commit,
token: options.token
}, function (err, res) {
if (err) return callback(err)
callback(null, fork, res)
})
})
}
}
}
},{"./branch-create":7,"./fork-create":10,"./fork-list":11,"./latest-commit":13,"xhr":43}],10:[function(require,module,exports){
var request = require('xhr')
module.exports = function fork (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/forks',
headers: { authorization: 'token ' + options.token },
method: 'POST'
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
body = JSON.parse(body)
callback(err, body)
})
}
},{"xhr":43}],11:[function(require,module,exports){
var request = require('xhr')
module.exports = function fork (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/forks',
headers: { authorization: 'token ' + options.token },
json: true
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
callback(err, body)
})
}
},{"xhr":43}],12:[function(require,module,exports){
module.exports = {
createFork: require('./fork-create'),
listForks: require('./fork-list'),
createPullRequest: require('./pull-request'),
forkAndBranch: require('./fork-and-branch'),
latestCommit: require('./latest-commit'),
createCommit: require('./commit-create'),
getBlob: require('./blob-get'),
updateBlob: require('./blob-update')
}
},{"./blob-get":5,"./blob-update":6,"./commit-create":8,"./fork-and-branch":9,"./fork-create":10,"./fork-list":11,"./latest-commit":13,"./pull-request":14}],13:[function(require,module,exports){
var request = require('xhr')
module.exports = function fork (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/commits',
headers: { authorization: 'token ' + options.token },
data: { sha: options.github.branch },
json: true
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
callback(err, body[0])
})
}
},{"xhr":43}],14:[function(require,module,exports){
var request = require('xhr')
module.exports = function pullRequest (options, callback) {
var requestOptions = {
url: 'https://api.github.com/repos/' + options.github.owner + '/' + options.github.repo + '/pulls',
headers: { authorization: 'token ' + options.token },
method: 'POST',
json: {
title: options.title,
head: options.user + ':' + options.head,
base: options.base
// TODO: body message, maybe something like: body: 'Pull request created by Submit Data'
}
}
request(requestOptions, function (err, res, body) {
if (err) return callback(err)
if (body.message === 'Not Found') return callback(new Error(body.message))
callback(err, body)
})
}
},{"xhr":43}],15:[function(require,module,exports){
var createAuth = require('github-static-auth')
var createStore = require('store-emitter')
var serialize = require('form-serialize')
var cookie = require('cookie-cutter')
var extend = require('xtend')
var el = require('yo-yo')
var config = require('./config')
var data = require('./data.json')
var modify = require('./modify-state')
var github = require('./github')
var formUI = require('./form')
var createAuthUI = require('./elements/auth')
var token = cookie.get(config.site.slug)
var auth = createAuth({
githubSecretKeeper: config.proxy,
githubClientId: config.client_id
})
var authUI = createAuthUI(config, {
onLogOut: function (e) {
e.preventDefault()
cookie.set(config.site.slug, '', { expires: new Date(0) })
store({ type: 'user:logout' })
}
})
var store = createStore(modify, {
site: config.site,
github: config.github,
data: data,
submitted: false,
loading: true,
flash: null,
modal: null,
user: null,
item: {},
origin: null,
fork: null
})
store.on('*', function (action, state) {
el.update(document.getElementById('app'), render(state))
})
function render (state) {
return layout(state)
}
document.body.appendChild(render(store.initialState()))
if (token) {
auth.getProfile(token, function (err, profile) {
if (err) return store({ type: 'error', error: err })
store({ type: 'loading:complete' })
store({ type: 'user:login', profile: profile, token: token })
})
} else if (auth.getCode()) {
auth.login(function (err, profile, token) {
if (err) return store({ type: 'error', error: err })
store({ type: 'loading:complete' })
store({ type: 'user:login', profile: profile, token: token })
cookie.set(config.site.slug, token)
window.location = config.redirect_uri
})
} else {
store({ type: 'loading:complete' })
}
function form (state) {
function onsubmit (e) {
e.preventDefault()
store({ type: 'loading' })
var fields = serialize(e.target, { hash: true, empty: true })
store({ type: 'form:submit', fields: fields })
var opts = { github: state.github, token: state.user.token, user: state.user.profile.login }
github.forkAndBranch(opts, getBranch)
function getBranch (err, fork, branch) {
if (err) return store({ type: 'error', error: err })
var opts = {
github: { owner: fork.owner.login, repo: state.github.repo },
token: state.user.token,
ref: branch.ref,
path: state.site.data
}
github.getBlob(opts, writeBlob)
function writeBlob (err, res, file) {
if (err) return store({ type: 'error', error: err })
file.push(fields)
var opts = {
github: { owner: fork.owner.login, repo: state.github.repo },
token: state.user.token,
ref: branch.ref,
path: state.site.data,
content: JSON.stringify(file),
sha: res.sha,
branch: branch.ref.split('/')[2],
message: 'Updated ' + state.site.data
}
github.updateBlob(opts, pullRequest)
}
function pullRequest (err, res) {
if (err) return store({ type: 'error', error: err })
var opts = {
github: state.github,
user: state.user.profile.login,
token: state.user.token,
title: 'Add new item to ' + state.site.data,
head: branch.ref,
base: state.github.branch
}
github.createPullRequest(opts, function (err, res) {
store({ type: 'loading:complete' })
store({
type: 'submitted',
fork: fork,
branch: branch,
pullRequest: res
})
})
}
}
}
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel1 = document.createElement("div")
bel1.setAttribute("class", "form")
var bel0 = document.createElement("h1")
appendChild(bel0, ["Submit a new item"])
appendChild(bel1, ["\n ",bel0,"\n ",arguments[0],"\n "])
return bel1
}(formUI(state, { onsubmit: onsubmit })))
}
function content (state) {
var elements
if (state.loading) elements = loading(state)
else if (state.user && state.submitted) elements = thanks(state)
else if (state.user) elements = form(state)
else elements = landing(state)
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel1 = document.createElement("main")
bel1.setAttribute("role", "main")
bel1.setAttribute("main", "main")
bel1.setAttribute("class", "site-content")
var bel0 = document.createElement("div")
bel0.setAttribute("class", "container")
appendChild(bel0, ["\n ",arguments[0],"\n "])
appendChild(bel1, ["\n ",bel0,"\n "])
return bel1
}(elements))
}
function loading (state) {
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel1 = document.createElement("div")
bel1.setAttribute("style", "-webkit-transform:scale(0.3)")
bel1.setAttribute("class", "loading uil-reload-css")
var bel0 = document.createElement("div")
appendChild(bel1, [bel0])
return bel1
}())
}
function thanks (state) {
console.log('thanks state', state)
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel9 = document.createElement("div")
bel9.setAttribute("class", "thanks")
var bel0 = document.createElement("h1")
appendChild(bel0, ["Thanks for your submission!"])
var bel2 = document.createElement("p")
var bel1 = document.createElement("a")
bel1.setAttribute("href", arguments[0])
appendChild(bel1, ["#",arguments[1]," - ",arguments[2]])
appendChild(bel2, ["Your pull request: ",bel1])
var bel4 = document.createElement("p")
var bel3 = document.createElement("a")
bel3.setAttribute("href", arguments[3])
appendChild(bel3, [arguments[4]])
appendChild(bel4, ["Your fork: ",bel3])
var bel6 = document.createElement("p")
var bel5 = document.createElement("a")
bel5.setAttribute("href", "http://github.com/editdata/submit-data")
appendChild(bel5, ["submit-data"])
appendChild(bel6, ["More about this project: ",bel5])
var bel8 = document.createElement("p")
var bel7 = document.createElement("a")
bel7.setAttribute("href", "http://about.editdata.org")
appendChild(bel7, ["about.editdata.org"])
appendChild(bel8, ["More about EditData: ",bel7])
appendChild(bel9, ["\n ",bel0,"\n ",bel2,"\n ",bel4,"\n ",bel6,"\n ",bel8,"\n "])
return bel9
}(state.pullRequest.html_url,state.pullRequest.number,state.pullRequest.title,state.fork.html_url,state.fork.full_name))
}
function landing (state) {
var url = 'https://github.com/login/oauth/authorize' +
'?client_id=' + config.client_id +
'&scope=' + config.scope +
'&redirect_uri=' + config.redirect_uri
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel4 = document.createElement("div")
bel4.setAttribute("class", "landing")
var bel0 = document.createElement("h1")
appendChild(bel0, ["Create a pull request via the GitHub API"])
var bel1 = document.createElement("h2")
appendChild(bel1, ["Log in to add an item to a JSON file by filling out a form!"])
var bel2 = document.createElement("p")
appendChild(bel2, ["This site will create a fork of this repo on your account, create a branch for your submission, save your submission, then create a pull request on the source repository."])
var bel3 = document.createElement("a")
bel3.setAttribute("href", arguments[0])
bel3.setAttribute("class", "profile-login button")
appendChild(bel3, ["Sign in with GitHub"])
appendChild(bel4, ["\n ",bel0,"\n ",bel1,"\n ",bel2,"\n ",bel3,"\n "])
return bel4
}(url))
}
function header (state) {
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel2 = document.createElement("header")
bel2.setAttribute("class", "app-header")
var bel1 = document.createElement("div")
bel1.setAttribute("class", "container")
var bel0 = document.createElement("h1")
bel0.setAttribute("class", "app-title")
appendChild(bel0, [arguments[0]])
appendChild(bel1, ["\n ",bel0,"\n ",arguments[1],"\n "])
appendChild(bel2, ["\n ",bel1,"\n "])
return bel2
}(state.site.title,authUI.render(state)))
}
function layout (state) {
return (function () {
function appendChild (el, childs) {
if (!Array.isArray(childs)) return
for (var i = 0; i < childs.length; i++) {
var node = childs[i];
if (Array.isArray(node)) {
appendChild(el, node)
continue
}
if (typeof node === "number" ||
typeof node === "boolean" ||
node instanceof Date ||
node instanceof RegExp) {
node = node.toString()
}
if (typeof node === "string") {
if (el.lastChild && el.lastChild.nodeName === "#text") {
el.lastChild.nodeValue += node
continue
}
node = document.createTextNode(node)
}
if (node && node.nodeType) {
el.appendChild(node)
}
}
}
var bel0 = document.createElement("div")
bel0.setAttribute("id", "app")
appendChild(bel0, ["\n ",arguments[0],"\n ",arguments[1],"\n "])
return bel0
}(header(state),content(state)))
}
},{"./config":1,"./data.json":2,"./elements/auth":3,"./form":4,"./github":12,"./modify-state":16,"cookie-cutter":20,"form-serialize":22,"github-static-auth":23,"store-emitter":40,"xtend":45,"yo-yo":46}],16:[function(require,module,exports){
var extend = require('xtend')
var modifiers = {
'loading': function (action, state) {
return extend(state, { loading: true })
},
'loading:complete': function (action, state) {
return extend(state, { loading: false })
},
'user:login': function (action, state) {
return extend(state, {
user: {
profile: action.profile,