You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/01/31 18:32:18 UTC
[royale-asjs] 01/02: GitHubCommitViewer source for tutorial
This is an automated email from the ASF dual-hosted git repository.
aharui pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 6ad062b144c3acbdf655ed752d839fd705d67a72
Author: Alex Harui <ah...@apache.org>
AuthorDate: Wed Jan 31 10:27:59 2018 -0800
GitHubCommitViewer source for tutorial
---
examples/express/GitHubCommitLogViewer/build.xml | 58 +++++++++++++
examples/express/GitHubCommitLogViewer/pom.xml | 73 ++++++++++++++++
.../src/main/resources/project.json | 4 +
.../src/main/royale/GitHubCommitLogViewer.mxml | 97 ++++++++++++++++++++++
.../src/main/royale/LogEntry.as | 29 +++++++
5 files changed, 261 insertions(+)
diff --git a/examples/express/GitHubCommitLogViewer/build.xml b/examples/express/GitHubCommitLogViewer/build.xml
new file mode 100644
index 0000000..d1346e5
--- /dev/null
+++ b/examples/express/GitHubCommitLogViewer/build.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+
+
+<project name="githubcommitlogviewer" default="main" basedir=".">
+ <property name="ROYALE_HOME" location="../../.."/>
+ <property name="example" value="GitHubCommitLogViewer" />
+
+ <property file="${ROYALE_HOME}/env.properties"/>
+ <property environment="env"/>
+ <property file="${ROYALE_HOME}/build.properties"/>
+ <property name="ROYALE_HOME" value="${ROYALE_HOME}"/>
+ <property name="opt1_arg" value="-js-output-optimization=skipAsCoercions" />
+
+ <include file="${basedir}/../../build_example.xml" />
+
+ <target name="main" depends="clean,build_example.compile" description="Clean build of ${example}">
+ <copy file="${basedir}/src/main/resources/project.json" tofile="${basedir}/bin-debug/project.json" />
+ <copy file="${basedir}/src/main/resources/project.json" tofile="${basedir}/bin/js-debug/project.json" />
+ <copy file="${basedir}/src/main/resources/project.json" tofile="${basedir}/bin/js-release/project.json" />
+ </target>
+
+ <target name="clean">
+ <delete dir="${basedir}/bin" failonerror="false" />
+ <delete dir="${basedir}/bin-debug" failonerror="false" />
+ <delete dir="${basedir}/bin-release" failonerror="false" />
+ <delete dir="${basedir}/target" failonerror="false" />
+ </target>
+
+ <target name="examine" depends="build_example.get.browser">
+ <property name="which" value="debug" />
+ <echo message="Log entries should appear. Select one and see if commit message appears below datagrid."/>
+ <exec executable="${browser}" dir="${basedir}/bin-${which}" failonerror="true">
+ <arg value="${basedir}/bin-${which}/${example}.html"/>
+ </exec>
+ <exec executable="${browser}" dir="${basedir}/bin/js-${which}" failonerror="true">
+ <arg value="${basedir}/bin/js-${which}/index.html"/>
+ </exec>
+ </target>
+
+</project>
diff --git a/examples/express/GitHubCommitLogViewer/pom.xml b/examples/express/GitHubCommitLogViewer/pom.xml
new file mode 100644
index 0000000..e97ce48
--- /dev/null
+++ b/examples/express/GitHubCommitLogViewer/pom.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<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>
+
+ <parent>
+ <groupId>org.apache.royale.examples</groupId>
+ <artifactId>examples-express</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>GitHubCommitLogViewer</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ <packaging>swf</packaging>
+
+ <name>Apache Royale: Examples: Express: GitHubCommitLogViewer</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.royale.compiler</groupId>
+ <artifactId>royale-maven-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <mainClass>GitHubCommitLogViewer.mxml</mainClass>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.adobe.flash.framework</groupId>
+ <artifactId>playerglobal</artifactId>
+ <version>${flash.version}</version>
+ <type>swc</type>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
+ <artifactId>Network</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>swf</classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.royale.framework</groupId>
+ <artifactId>Network</artifactId>
+ <version>0.9.1-SNAPSHOT</version>
+ <type>swc</type>
+ <classifier>js</classifier>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/examples/express/GitHubCommitLogViewer/src/main/resources/project.json b/examples/express/GitHubCommitLogViewer/src/main/resources/project.json
new file mode 100644
index 0000000..59d664e
--- /dev/null
+++ b/examples/express/GitHubCommitLogViewer/src/main/resources/project.json
@@ -0,0 +1,4 @@
+{ "license" : "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements; and to You under the Apache License, Version 2.0. ",
+ "projectName": "Apache Royale",
+ "repos": [ "apache/royale-asjs", "apache/royale-typedefs", "apache/royale-compiler" ]
+}
diff --git a/examples/express/GitHubCommitLogViewer/src/main/royale/GitHubCommitLogViewer.mxml b/examples/express/GitHubCommitLogViewer/src/main/royale/GitHubCommitLogViewer.mxml
new file mode 100644
index 0000000..f4d8a5c
--- /dev/null
+++ b/examples/express/GitHubCommitLogViewer/src/main/royale/GitHubCommitLogViewer.mxml
@@ -0,0 +1,97 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<js:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
+xmlns:local="*"
+xmlns:js="library://ns.apache.org/royale/express"
+initialize="addEventListener('dataReady', dataReadyHandler);configurator.send()"
+>
+<fx:Script>
+<![CDATA[
+ import org.apache.royale.collections.ArrayList;
+ import org.apache.royale.events.Event;
+
+ public const commits:Array = [];
+ public var repos:Array;
+ [Bindable]
+ public var projectName:String;
+
+ private function setConfig():void
+ {
+ repos = configurator.json.repos;
+ projectName = configurator.json.projectName;
+ }
+
+ private var currentIndex:int = 0;
+
+ private function fetchCommits():void
+ {
+ commitsService.addEventListener("complete", gotCommits);
+ commitsService.url = "https://api.github.com/repos/" + repos[currentIndex] + "/commits";
+ commitsService.send();
+ }
+
+ private function gotCommits(event:Event):void
+ {
+ currentIndex++;
+ var results:Array = commitsService.json as Array;
+ var n:int = results.length;
+ for (var i:int = 0; i < n; i++)
+ {
+ var obj:Object = results[i];
+ var data:LogEntry = new LogEntry();
+ var commitObj:Object = obj["commit"];
+ var authorObj:Object = commitObj["author"];
+ data.author = authorObj["name"];
+ // clip date after yyyy-mm-dd
+ data.date = authorObj["date"].substr(0, 10);
+ data.message = commitObj.message;
+ commits.push(data);
+ }
+ if (currentIndex < repos.length)
+ fetchCommits();
+ else
+ dispatchEvent(new Event("dataReady"));
+ }
+
+ private function dataReadyHandler(event:Event):void
+ {
+ dg.dataProvider = new ArrayList(commits);
+ }
+
+]]>
+</fx:Script>
+<js:HTTPService id="configurator" url="project.json" complete="setConfig();fetchCommits()" />
+<js:HTTPService id="commitsService" />
+
+<js:initialView>
+ <js:VView>
+ <js:Label text="{projectName} Commits Log"/>
+ <js:DataGrid id="dg" width="600" height="300">
+ <js:columns>
+ <js:DataGridColumn label="Date" dataField="date" columnWidth="100"/>
+ <js:DataGridColumn label="Author" dataField="author" columnWidth="100"/>
+ <js:DataGridColumn label="Message" dataField="message" columnWidth="400"/>
+ </js:columns>
+ </js:DataGrid>
+ <js:Label text="Selected Message:"/>
+ <js:MultilineLabel text="{LogEntry(commits[dg.selectedIndex]).message}" width="600" />
+ </js:VView>
+</js:initialView>
+</js:Application>
diff --git a/examples/express/GitHubCommitLogViewer/src/main/royale/LogEntry.as b/examples/express/GitHubCommitLogViewer/src/main/royale/LogEntry.as
new file mode 100644
index 0000000..942e0a5
--- /dev/null
+++ b/examples/express/GitHubCommitLogViewer/src/main/royale/LogEntry.as
@@ -0,0 +1,29 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package {
+
+public class LogEntry
+{
+ public var date:String;
+ public var author:String;
+
+ [Bindable("__NoChangeEvent__")]
+ public var message:String;
+}
+}
--
To stop receiving notification emails like this one, please contact
aharui@apache.org.