Skip to content

Commit

Permalink
First draft:
Browse files Browse the repository at this point in the history
* twitter emoji files added (v2 only)
* Wrapper added
* basic usage added
* pom.xml is used to create the jar
* jar is usable in other gwt projects
  • Loading branch information
nbartels committed May 21, 2018
1 parent 426bd7d commit 4241938
Show file tree
Hide file tree
Showing 8,075 changed files with 1,358,932 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target/
*.iml
.idea/
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
gwt-twemoji
===========

This project aims to wrap the Twitter Emoji (https://github.com/twitter/twemoji) with GWT.

Basic Usage
-----------
Twemoji twemoji = new Twemoji();
twemoji.init(); // init the wrapper
String stringWithReplacedEmojis = twemoji.parse(strinWithUnicodes);
47 changes: 47 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.phpmonkeys</groupId>
<artifactId>gwt-twemoji</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>

<properties>
<gwt.version>2.7.0</gwt.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<version>${gwt.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<resources>
<!-- bundle sources with the jar, so they are visible to GWT's compiler -->
<!-- bundle the module descriptor with the jar, so it is visible to GWT's
compiler -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.java</include>
<include>**/*.gwt.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/72x72/*</include>
<include>**/*.js</include>
</includes>
</resource>
</resources>
</build>
</project>
8 changes: 8 additions & 0 deletions src/main/java/de/phpmonkeys/gwt/twemoji/Gwttwemoji.gwt.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source/core/src/gwt-module.dtd">
<module>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User'/>

<public path="public"/>
</module>
43 changes: 43 additions & 0 deletions src/main/java/de/phpmonkeys/gwt/twemoji/client/Twemoji.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package de.phpmonkeys.gwt.twemoji.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.ScriptInjector;

public class Twemoji {

private String baseUrl;

public Twemoji() {
baseUrl = GWT.getModuleBaseURL() + "twemoji/";
}

public void init() {
injectScript();
initNative(baseUrl);
}

private final native void initNative(String baseUrl)/*-{
$wnd.twemoji.base = baseUrl;
}-*/;

public String parse(String htmlString) {
return parseNative(htmlString);
}

private final native String parseNative(String htmlString)/*-{
return $wnd.twemoji.parse(htmlString);
}-*/;

private void injectScript() {
if (!isInjected()) {
ScriptInjector.fromString(TwemojiClientBundle.INSTANCE.twemojiJs().getText()).setWindow(ScriptInjector.TOP_WINDOW).inject();
}
}

private native final boolean isInjected() /*-{
if (!(typeof $wnd.twemoji === "undefined") && !(null===$wnd.twemoji)) {
return true;
}
return false;
}-*/;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package de.phpmonkeys.gwt.twemoji.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.TextResource;

public interface TwemojiClientBundle extends ClientBundle {

TwemojiClientBundle INSTANCE = GWT.create(TwemojiClientBundle.class);

@Source("resources/twemoji.min.js")
TextResource twemojiJs();
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4241938

Please sign in to comment.