Skip to content

Commit 9ac77b3

Browse files
committed
Add Emoji Info and Demo
1 parent 305d1bc commit 9ac77b3

File tree

3 files changed

+94
-0
lines changed

3 files changed

+94
-0
lines changed

example/emoji.dart

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
}

example/emoji.html

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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>

lib/src/common/github.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,15 @@ class GitHub {
447447
return input.map((it) => User.fromJSON(github, it));
448448
});
449449
}
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+
}
450459

451460
/**
452461
* Fetches repositories that the current user is watching. If [user] is specified, it will get the watched repositories for that user.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy