Skip to content
This repository has been archived by the owner on Mar 29, 2024. It is now read-only.

Use Component API #43

Merged
merged 29 commits into from
Jan 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c259215
specify coding style
ztl8702 Sep 23, 2017
1f25486
component-ise the "play audio button"
ztl8702 Sep 23, 2017
01fa296
coding style: rename controllers
ztl8702 Sep 23, 2017
e3cb772
suppress error message when audio url is undefined
ztl8702 Sep 23, 2017
8df696d
new component "canvas-character"
ztl8702 Sep 30, 2017
be8b3c1
Create fi-header component
ztl8702 Jan 12, 2018
235e460
create new component fi-mainview
ztl8702 Jan 12, 2018
6bb3b7d
downgrade office-ui-fabric to 1.2.1 for compatibility
ztl8702 Jan 12, 2018
8ca171a
create new component share-panel
ztl8702 Jan 12, 2018
7358780
componentise rhe sidebar as fi-sidebar
ztl8702 Jan 12, 2018
fec9905
switch to ui-router for routing
ztl8702 Jan 12, 2018
9bc1c0a
componentise the details page
ztl8702 Jan 12, 2018
311d18a
new component: apps-page
ztl8702 Jan 12, 2018
0d3be1d
new component: help-page
ztl8702 Jan 12, 2018
87b9f52
new component: landing-page
ztl8702 Jan 12, 2018
fbb0279
new component: category-page
ztl8702 Jan 12, 2018
264093b
clean up
ztl8702 Jan 12, 2018
5dda678
some minor cleaning
ztl8702 Jan 12, 2018
cee8033
update gulp and gulpfile.js
ztl8702 Jan 12, 2018
374911b
set up travis ci
ztl8702 Jan 12, 2018
80c0228
update .travis.yml
ztl8702 Jan 12, 2018
4d5ec1b
add yarn
ztl8702 Jan 12, 2018
5ecf4e9
before_script
ztl8702 Jan 12, 2018
b6ea02c
change folder
ztl8702 Jan 12, 2018
66f158d
change build out dir
ztl8702 Jan 12, 2018
92ca058
update
ztl8702 Jan 12, 2018
aca2db9
update
ztl8702 Jan 12, 2018
3632ede
Merge pull request #70 from MindongLab/radium/ci
ztl8702 Jan 12, 2018
0e5691e
get ready for CI on master branch
ztl8702 Jan 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
dist: trusty
sudo: false
language: node_js
node_js: node
before_script:
- npm install -g gulp-cli bower
- cd ./www
- yarn install
- bower install
script:
- gulp build:prod
deploy:
provider: pages
skip-cleanup: true
local-dir: build
repo: MindongLab/foochow-idioms-web
github-token: $GITHUB_TOKEN # Set in travis-ci.org dashboard, marked secure
keep-history: true
target-branch: gh-pages
on:
branch: master
1 change: 1 addition & 0 deletions www/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
idioms.mindong.asia
9 changes: 6 additions & 3 deletions www/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# Web UI for Foochow Idioms

## Build steps
## Local development
```
npm install
yarn install
bower install
gulp serve::dev
gulp serve:dev
```

## Coding Style
Follow the [AngularJS Style Guide](https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#controllers) for now.
54 changes: 30 additions & 24 deletions www/app/app.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
"use strict";
angular.module('app', ['ngRoute'])
.constant("SERVER_API_URL","http://127.0.0.1:5000/api")
.constant("SERVER_AUDIO_URL","/assets/audio/")

.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/views/welcome.tpl.html',
controller: 'homeCtrl'
angular.module('app', ['ui.router'])
.constant("SERVER_API_URL",/** inject:SERVER_API_URL **/"http://fiapi.radiumz.org:2052/api"/** endinject **/)
.constant("SERVER_AUDIO_URL",/** inject:SERVER_AUDIO_URL **/"/assets/audio/"/** endinject **/)
.constant("CI_BUILD_NUMBER",/** inject:CI_BUILD_NUMBER **/"dev"/** endinject **/)
.constant("CI_COMMIT_HASH",/** inject:CI_COMMIT_HASH **/"dev"/** endinject **/)
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state({
name: 'home',
url: '/',
component: 'landingPage'
})
.when('/idiom/:idiomtext*', {
templateUrl: 'app/views/showDetails.tpl.html',
controller: 'detailsCtrl',
.state({
name: 'showidiom',
url: '/idiom/{idiomtext}',
component: 'viewIdiomPage',
caseInsensitiveMatch: true
})
.when('/help', {
templateUrl: 'app/views/help.tpl.html'
// controller: 'mainCtrl'
})
.when('/tags', {
templateUrl: 'app/views/tags.tpl.html' ,
controller: 'tagsCtrl'
.state({
name: 'showhelp',
url: '/help',
component: 'helpPage'
})
.when('/apps', {
templateUrl: 'app/views/apps.tpl.html'
.state({
name: 'showcategories',
url: '/tags',
component: 'categoryPage'
})
.otherwise({
redirectTo: '/'
.state({
name: 'showapps',
url: '/apps',
component: 'appsPage'
});

$urlRouterProvider.otherwise('/');
}]);

require('./controllers');
require('./components');
require('./services');
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<div style="padding:20px">
<h1 class="ms-font-su ms-fontColor-themePrimary">下载 App</h1>
<h2 class="ms-font-xl ms-fontColor-themePrimary">福州话熟语大全 Android 版</h2>
<div class="ms-font-l ms-fontColor-themePrimary">
<ul>
<li>离线发音,无需联网</li>
<li>轻松分享字图到社交软件</li>
</ul>
<a href="http://www.wandoujia.com/apps/org.mindonglab.foochowidioms" target="_blank">
<button class="ms-Button ms-Button--primary" style="background-color: #107c10; border-color: #107c10;">
<span class="ms-Button-icon">
<i class="ms-Icon ms-Icon--plus"></i>
</span>
<span class="ms-Button-label">豌豆荚下载</span>
</button></a>
<a href="http://idioms.mindong.asia/assets/android.apk" target="_blank">
<button class="ms-Button ms-Button--primary">
<span class="ms-Button-icon">
<i class="ms-Icon ms-Icon--plus"></i>
</span>
<span class="ms-Button-label">下载Apk</span>
</button></a>
<div>
<a href='https://play.google.com/store/apps/details?id=org.mindonglab.foochowidioms&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'>
<img alt='下载应用,请到 Google Play' style="max-height: 60px"
src='assets/img/google-play-badge.png'/>
</a>
</div>
</div>
<h2 class="ms-font-xl ms-fontColor-themePrimary">iOS 版 开发中</h2>
<div style="padding:20px">

<h1 class="ms-font-su ms-fontColor-themePrimary">下载 App</h1>
<h2 class="ms-font-xl ms-fontColor-themePrimary">福州话熟语大全 Android 版</h2>
<div class="ms-font-l ms-fontColor-themePrimary">
<ul>
<li>离线发音,无需联网</li>
<li>轻松分享字图到社交软件</li>
</ul>
<a href="http://www.wandoujia.com/apps/org.mindonglab.foochowidioms" target="_blank">
<button class="ms-Button ms-Button--primary" style="background-color: #107c10; border-color: #107c10;">
<span class="ms-Button-icon">
<i class="ms-Icon ms-Icon--plus"></i>
</span>
<span class="ms-Button-label">豌豆荚下载</span>
</button>
</a>
<a href="http://www.wandoujia.com/apps/org.mindonglab.foochowidioms/download?pos=detail-ndownload-org.mindonglab.foochowidioms" target="_blank">
<button class="ms-Button ms-Button--primary">
<span class="ms-Button-icon">
<i class="ms-Icon ms-Icon--plus"></i>
</span>
<span class="ms-Button-label">下载Apk</span>
</button>
</a>
<div>
<a href='https://play.google.com/store/apps/details?id=org.mindonglab.foochowidioms&pcampaignid=MKT-Other-global-all-co-prtnr-py-PartBadge-Mar2515-1'>
<img alt='下载应用,请到 Google Play' style="max-height: 60px" src='assets/img/google-play-badge.png' />
</a>
</div>
</div>
<h2 class="ms-font-xl ms-fontColor-themePrimary">iOS 版 开发中</h2>
</div>
12 changes: 12 additions & 0 deletions www/app/components/apps-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

function AppsPageController() {

};

var AppsPage = {
template: require('./apps-page.component.html'),
controller: AppsPageController
}

module.exports = AppsPage;
1 change: 1 addition & 0 deletions www/app/components/canvas-character.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span ng-style="$ctrl.style"></span><a style="font-size:0">{{$ctrl.altText}}</a>
52 changes: 52 additions & 0 deletions www/app/components/canvas-character.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'use strict';

// 用於顯示非Unicode或Unicode擴展區漢字的元件

function CanvasCharacterController($scope, KageService) {
var ctrl = this;

ctrl.altText = ""; // 用於 accessibility 的隱藏文字 (方便複製文本和 screen reader)
ctrl.imgBase64Url = "";

function updateText() {
var requestedText = (ctrl.ids != '') ? ctrl.ids : ctrl.char;
ctrl.altText = requestedText;
console.log("[canvas-character] requesting IDS "+requestedText);
ctrl.style = {
'height': ctrl.size,
'width': ctrl.size,
'background': 'url("'+ctrl.imgBase64Url+'")',
'background-size': 'contain',
'display': 'inline-block',
'vertical-align': -5
};
KageService.getGlyphImage(requestedText, 200, 1).then(
(r)=> {
console.log('got it:',r);
ctrl.imgBase64Url = r.data;
ctrl.style['background'] = 'url("'+ctrl.imgBase64Url+'")';
}
);
}
ctrl.$onChanges = () => {
updateText();
};
ctrl.$onInit = () => {
updateText();
};

}

CanvasCharacterController.$inject = ['$scope', 'KageService'];

var CanvasCharacter = {
template: require('./canvas-character.component.html'),
bindings: {
char: '@', // character to be displayed
ids: '@', // ids to be displayed (`ids` is prioritised over `char`)
size: '@' // size of the character image (=height=width)
},
controller: CanvasCharacterController
}

module.exports = CanvasCharacter;
3 changes: 3 additions & 0 deletions www/app/components/category-page.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div style="padding:20px">
<h2 class="ms-font-xl ms-fontColor-themePrimary" ng-repeat="item in $ctrl.list" ng-click="$ctrl.tagClicked(item)">{{item}}</h2>
</div>
22 changes: 22 additions & 0 deletions www/app/components/category-page.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

function CategoryPageController($scope, $rootScope, $location, dataService) {
var ctrl = this;
dataService.getAllTags().then(function (r) {
ctrl.list = r;
})

ctrl.tagClicked = function (tagName) {
$rootScope.$emit("switchToTag", {'tag': tagName});
$rootScope.$emit("toggleSidebar", {'state': true});
};
}

CategoryPageController.$inject = ['$scope', '$rootScope', '$location', "DataService"];

var CategoryPage = {
template: require('./category-page.component.html'),
controller: CategoryPageController
}

module.exports = CategoryPage;
7 changes: 7 additions & 0 deletions www/app/components/fi-mainview.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div id="mainContainer" ng-cloak>

<fi-sidebar></fi-sidebar>
<div id="mainPane">
<ui-view></ui-view>
</div>
</div>
14 changes: 14 additions & 0 deletions www/app/components/fi-mainview.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict';

function FiMainviewController() {

};

FiMainviewController.$inject = [];

var FiMainview = {
template: require('./fi-mainview.component.html'),
controller: FiMainviewController
}

module.exports = FiMainview;
31 changes: 31 additions & 0 deletions www/app/components/fi-sidebar.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div id="sideBar" class="ms-bgColor-themeLight sideBarHide">

<div style="display:flex; flex-direction:row;">
<div class="tagButton" ng-class="{'tagButton-hide':!($ctrl.tagName.length)}" style="order:1">
<div class="tagButton-text ms-Font-m">
{{$ctrl.tagName}}
</div>
<div ng-click="$ctrl.removeTagClicked()" class="tagButton-removeButton">
<i class="ms-Icon ms-Icon--x"></i>
</div>

</div>
<div class="filterSearch ms-SearchBox" style="order:2; flex-grow:100;">
<input class="ms-SearchBox-field SearchBox" ng-model="filterString">
<label class="ms-SearchBox-label">
<i class="ms-SearchBox-icon ms-Icon ms-Icon--search"></i>搜索
</label>
<button class="ms-SearchBox-closeButton">
<i class="ms-Icon ms-Icon--x"></i>
</button>
</div>
</div>
<ul class="ms-List resultList">
<div ng-repeat="item in filteredList = ($ctrl.list | filter:filterString)" class="cListItem is-selectable" ng-click="$ctrl.listItemClicked(item)">
<span class="cListItem-primaryText ms-Font-xl">{{item}}</span>
</div>
<div ng-show="$ctrl.loading" class="ms-Spinner"></div>
<div ng-show="$ctrl.loaded && filteredList.length==0" class="ms-Font-xl">没有符合条件的结果</div>

</ul>
</div>
Loading