File tree Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Expand file tree Collapse file tree 3 files changed +94
-0
lines changed Original file line number Diff line number Diff line change
1
+ import "dart:html" ;
2
+
3
+ import "package:github/browser.dart" ;
4
+ import "common.dart" ;
5
+
6
+ GitHub github;
7
+ DivElement $emoji;
8
+
9
+ void main () {
10
+ initGitHub ();
11
+ init ("emoji.dart" , onReady: () {
12
+ $emoji = querySelector ("#emojis" );
13
+ loadEmojis ();
14
+ });
15
+ }
16
+
17
+ void loadEmojis () {
18
+ var token = "5fdec2b77527eae85f188b7b2bfeeda170f26883" ;
19
+ var url = window.location.href;
20
+
21
+ if (url.contains ("?" )) {
22
+ var params = Uri .splitQueryString (url.substring (url.indexOf ('?' ) + 1 ));
23
+
24
+ if (params.containsKey ("token" )) {
25
+ token = params["token" ];
26
+ }
27
+ }
28
+
29
+ github = new GitHub (auth: new Authentication .withToken (token));
30
+
31
+ github.emojis ().then ((info) {
32
+ info.forEach ((name, url) {
33
+ var h = new DivElement ();
34
+ h.classes.add ("box" );
35
+ h.classes.add ("emoji-box" );
36
+ h.style.textAlign = "center" ;
37
+ h.append (new ImageElement (src: url, width: 64 , height: 64 )..classes.add ("emoji" ));
38
+ h.append (new ParagraphElement ()..text = name);
39
+ $emoji.append (h);
40
+ });
41
+ });
42
+ }
Original file line number Diff line number Diff line change
1
+ <!DOCTYPE html>
2
+ < html >
3
+
4
+ < head >
5
+ < title > GitHub Emoji</ title >
6
+
7
+ < style >
8
+ .line {
9
+ border-top : 1px ;
10
+ border-style : solid;
11
+ }
12
+
13
+ .box {
14
+ border : 2px solid;
15
+ }
16
+
17
+ .emoji-box {
18
+ display : inline-block;
19
+ margin-top : 5px ;
20
+ margin-left : 5px ;
21
+ width : 256px ;
22
+ }
23
+
24
+ .emoji {
25
+ margin-top : 5px ;
26
+ }
27
+ </ style >
28
+ </ head >
29
+
30
+ < body >
31
+ < div class ="header ">
32
+ < h1 > GitHub Emoji</ h1 >
33
+ < button id ="view-source "> View the Source</ button >
34
+ < p > </ p >
35
+ </ div >
36
+
37
+ < div id ="emojis "> </ div >
38
+
39
+ < script type ="application/dart " src ="emoji.dart "> </ script >
40
+ < script src ="packages/browser/dart.js "> </ script >
41
+ </ body >
42
+
43
+ </ html >
Original file line number Diff line number Diff line change @@ -447,6 +447,15 @@ class GitHub {
447
447
return input.map ((it) => User .fromJSON (github, it));
448
448
});
449
449
}
450
+
451
+ /**
452
+ * Fetches all emojis available on GitHub
453
+ *
454
+ * Returns a map of the name to a url of the image.
455
+ */
456
+ Future <Map <String , String >> emojis () {
457
+ return getJSON ("/emojis" , statusCode: 200 );
458
+ }
450
459
451
460
/**
452
461
* Fetches repositories that the current user is watching. If [user] is specified, it will get the watched repositories for that user.
You can’t perform that action at this time.
0 commit comments