Skip to content

Instantly share code, notes, and snippets.

@pukapukan
pukapukan / cors.js
Created March 5, 2016 06:11
API endpoint to return S3 CORS options for file upload
import Router from 'koa-router'
import crypto from 'crypto'
import path from 'path'
import uuid from 'node-uuid'
const router = new Router()
router.get('/s3options', function *(next) {
let { contentType, filename } = this.query
this.type = 'json'
<polymer-element name="my-app">
<template>
<my-layout on-board-changed={{onBoardChanged}}>
<template if="{{board == 'News'}}">
<my-news-board></my-news-board>
</template>
<template if="{{board == 'Discussions'}}">
<my-discussions-board></my-discussions-board>
</template>
</my-layout>
<polymer-element name="my-layout">
<template>
<core-localstorage name="selected-menu-index" value="{{selected}}" on-core-localstorage-load="{{onStorageLoad}}"></core-localstorage>
<core-scaffold>
<core-header-panel navigation flex>
<core-toolbar id="navheader">
<span>Polymer Board</span>
</core-toolbar>
<core-menu selected="{{selected}}">
<template repeat="{{menuItem in menu}}">
<polymer-element name="my-news-board" extends="my-firebase-board">
<template>
<shadow></shadow>
<template repeat="{{key in keys | sort(true)}}">
<my-board-card item="{{data[key]}}"></my-board-card>
</template>
</template>
<script>
(function () {
'use strict';
<polymer-element name="my-discussions-board" extends="my-firebase-board">
<template>
<shadow></shadow>
<template if={{dataReady}}>
<my-discussion-input ref="{{ref}}"></my-discussion-input>
<template repeat="{{key in keys | sort(true)}}">
<my-discussion-item item="{{data[key]}}"></my-discussion-item>
</template>
</template>
</template>
<polymer-element name="polymer-cool">
<template>
You are {{praise}} <content></content>!
</template>
<script>
Polymer({
praise: 'cool',
// 하위 element에 change watcher가 없으면
// polymer-cool의 changed watcher가 불려진다.
// praiseChanged: function() { },
<polymer-element name="polymer-cool">
<template>
You are {{praise}} <content></content>!
</template>
<script>
Polymer({
praise: 'cool'
});
</script>
</polymer-element>
<polymer-element name="my-firebase-board">
<template>
<my-globals id="globals"></my-globals>
<firebase-element id="base" location="{{location}}" childEvents="true" ref="{{ref}}" data="{{data}}" keys="{{keys}}" dataReady="{{dataReady}}"></firebase-element>
<template if={{!dataReady}}>
<div class="center">
<my-font-awesome attr="fa-circle-o-notch fa-spin fa-5x"></my-font-awesome>
</div>
</template>
<polymer-element name="my-board-card" attributes="item">
<template>
<paper-shadow>
<div class="card-header">
{{item.title}}
</div>
<div class="card-author">
<my-font-awesome attr="fa-user"></my-font-awesome>
<span class="author-name">&nbsp; {{item.author}}</span>
</div>
<polymer-element name="my-discussion-item" attributes="item">
<template>
<core-signals on-core-signal-user-changed="{{signalUserChanged}}"></core-signals>
<my-globals id="globals"></my-globals>
<div id="container">
<div class="profile">
<img src="{{profileUrl}}" on-click="{{openProviderPage}}">
</div>
<div class="pull-right created">{{item.created | ticksToDateString}}</div>