Formatted files. Using ds as prefix instead of dspace.

This commit is contained in:
William Welling
2016-12-01 12:32:54 -06:00
parent 9e96728761
commit 47b2de2aa4
23 changed files with 75 additions and 72 deletions

View File

@@ -27,7 +27,3 @@ Currently this contains the [Angular 2 Universal Starter](https://github.com/ang
## AoT and Prod ## AoT and Prod
- `npm run build:prod:ngc` to compile the ngfactory files and build prod - `npm run build:prod:ngc` to compile the ngfactory files and build prod

View File

@@ -3,5 +3,5 @@
"dist", "dist",
"src/index.html" "src/index.html"
], ],
"ext" : "js ts json html" "ext": "js ts json html"
} }

View File

@@ -8,14 +8,14 @@ let __compiler__ = require('@angular/compiler');
import { __platform_browser_private__ } from '@angular/platform-browser'; import { __platform_browser_private__ } from '@angular/platform-browser';
import { __core_private__ } from '@angular/core'; import { __core_private__ } from '@angular/core';
if (!__core_private__['ViewUtils']) { if (!__core_private__['ViewUtils']) {
__core_private__['ViewUtils'] = __core_private__['view_utils']; __core_private__['ViewUtils'] = __core_private__['view_utils'];
} }
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) { if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
(__compiler__).__compiler_private__ = { (__compiler__).__compiler_private__ = {
SelectorMatcher: __compiler__.SelectorMatcher, SelectorMatcher: __compiler__.SelectorMatcher,
CssSelector: __compiler__.CssSelector CssSelector: __compiler__.CssSelector
} }
} }

View File

@@ -9,25 +9,25 @@ import { __platform_browser_private__ } from '@angular/platform-browser';
import { __core_private__ } from '@angular/core'; import { __core_private__ } from '@angular/core';
let patch = false; let patch = false;
if (!__core_private__['ViewUtils']) { if (!__core_private__['ViewUtils']) {
patch = true; patch = true;
__core_private__['ViewUtils'] = __core_private__['view_utils']; __core_private__['ViewUtils'] = __core_private__['view_utils'];
} }
if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) { if (__compiler__ && __compiler__.SelectorMatcher && __compiler__.CssSelector) {
patch = true; patch = true;
(__compiler__).__compiler_private__ = { (__compiler__).__compiler_private__ = {
SelectorMatcher: __compiler__.SelectorMatcher, SelectorMatcher: __compiler__.SelectorMatcher,
CssSelector: __compiler__.CssSelector CssSelector: __compiler__.CssSelector
} }
} }
if (patch) { if (patch) {
var __universal__ = require('angular2-platform-node/__private_imports__'); var __universal__ = require('angular2-platform-node/__private_imports__');
__universal__.ViewUtils = __core_private__['view_utils']; __universal__.ViewUtils = __core_private__['view_utils'];
__universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector; __universal__.CssSelector = __universal__.CssSelector || __compiler__.CssSelector;
__universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher; __universal__.SelectorMatcher = __universal__.SelectorMatcher || __compiler__.SelectorMatcher;
} }
// Fix Material Support // Fix Material Support

View File

@@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.io/license * found in the LICENSE file at https://angular.io/license
*/ */
import {Injectable} from '@angular/core'; import { Injectable } from '@angular/core';
// es6-modules are used here // es6-modules are used here
import {DomAdapter, getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import { DomAdapter, getDOM } from '@angular/platform-browser/src/dom/dom_adapter';
/** /**
* Represent meta element. * Represent meta element.
@@ -69,7 +69,7 @@ export class Meta {
* @param tags * @param tags
* @returns {HTMLMetaElement[]} * @returns {HTMLMetaElement[]}
*/ */
addTags(...tags: Array<MetaDefinition|MetaDefinition[]>): HTMLMetaElement[] { addTags(...tags: Array<MetaDefinition | MetaDefinition[]>): HTMLMetaElement[] {
const presentTags = this._flattenArray(tags); const presentTags = this._flattenArray(tags);
if (presentTags.length === 0) return []; if (presentTags.length === 0) return [];
return presentTags.map((tag: MetaDefinition) => this._addInternal(tag)); return presentTags.map((tag: MetaDefinition) => this._addInternal(tag));

View File

@@ -5,7 +5,7 @@ import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/
encapsulation: ViewEncapsulation.Emulated, encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-app', selector: 'ds-app',
templateUrl: './app.component.html', templateUrl: './app.component.html',
styleUrls: [ './app.component.scss' ] styleUrls: ['./app.component.scss']
}) })
export class AppComponent { export class AppComponent {
} }

View File

@@ -8,7 +8,7 @@ import { AppComponent } from './app.component';
@NgModule({ @NgModule({
declarations: [ AppComponent ], declarations: [AppComponent],
imports: [ imports: [
SharedModule, SharedModule,
HomeModule, HomeModule,

View File

@@ -4,7 +4,7 @@ import { Component, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/
changeDetection: ChangeDetectionStrategy.Default, changeDetection: ChangeDetectionStrategy.Default,
encapsulation: ViewEncapsulation.Emulated, encapsulation: ViewEncapsulation.Emulated,
selector: 'ds-home', selector: 'ds-home',
styleUrls: [ './home.component.css' ], styleUrls: ['./home.component.css'],
templateUrl: './home.component.html' templateUrl: './home.component.html'
}) })
export class HomeComponent { export class HomeComponent {

View File

@@ -11,9 +11,9 @@ export class ApiService {
} }
/** /**
* whatever domain/feature method name * whatever domain/feature method name
*/ */
get(url: string, options?: any) { get(url: string, options?: any) {
return this._http.get(url, options) return this._http.get(url, options)
.map(res => res.json()) .map(res => res.json())

View File

@@ -4,7 +4,7 @@ import { Inject, Injectable, isDevMode } from '@angular/core';
export class CacheService { export class CacheService {
static KEY = 'CacheService'; static KEY = 'CacheService';
constructor(@Inject('LRU') public _cache: Map<string, any>) { constructor( @Inject('LRU') public _cache: Map<string, any>) {
} }

View File

@@ -23,14 +23,14 @@ export function hashCodeString(str: string): string {
// domain/feature service // domain/feature service
@Injectable() @Injectable()
export class ModelService { export class ModelService {
// This is only one example of one Model depending on your domain // This is only one example of one Model depending on your domain
constructor(public _api: ApiService, public _cache: CacheService) { constructor(public _api: ApiService, public _cache: CacheService) {
} }
/** /**
* whatever domain/feature method name * whatever domain/feature method name
*/ */
get(url) { get(url) {
// you want to return the cache if there is a response in it. // you want to return the cache if there is a response in it.
// This would cache the first response so if your API isn't idempotent // This would cache the first response so if your API isn't idempotent

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -1,9 +1,9 @@
var util = require('util'); var util = require('util');
var {Router} = require('express'); var { Router } = require('express');
// Our API for demos only // Our API for demos only
import {fakeDataBase} from './db'; import { fakeDataBase } from './db';
import {fakeDemoRedisCache} from './cache'; import { fakeDemoRedisCache } from './cache';
// you would use cookies/token etc // you would use cookies/token etc
var USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example var USER_ID = 'f9d98cf1-1b96-464e-8755-bcc2a5c09077'; // hardcoded as an example
@@ -32,9 +32,9 @@ export function serverApi(req, res) {
var COUNT = 4; var COUNT = 4;
var TODOS = [ var TODOS = [
{ id: 0, value: 'finish example', created_at: new Date(), completed: false }, { id: 0, value: 'finish example', created_at: new Date(), completed: false },
{ id: 1, value: 'add tests', created_at: new Date(), completed: false }, { id: 1, value: 'add tests', created_at: new Date(), completed: false },
{ id: 2, value: 'include development environment', created_at: new Date(), completed: false }, { id: 2, value: 'include development environment', created_at: new Date(), completed: false },
{ id: 3, value: 'include production environment', created_at: new Date(), completed: false } { id: 3, value: 'include production environment', created_at: new Date(), completed: false }
]; ];
export function createTodoApi() { export function createTodoApi() {
@@ -51,7 +51,7 @@ export function createTodoApi() {
}) })
.post(function(req, res) { .post(function(req, res) {
console.log('POST', util.inspect(req.body, {colors: true})); console.log('POST', util.inspect(req.body, { colors: true }));
var todo = req.body; var todo = req.body;
if (todo) { if (todo) {
TODOS.push({ TODOS.push({
@@ -81,12 +81,12 @@ export function createTodoApi() {
router.route('/todos/:todo_id') router.route('/todos/:todo_id')
.get(function(req, res) { .get(function(req, res) {
console.log('GET', util.inspect(req.todo, {colors: true})); console.log('GET', util.inspect(req.todo, { colors: true }));
res.json(req.todo); res.json(req.todo);
}) })
.put(function(req, res) { .put(function(req, res) {
console.log('PUT', util.inspect(req.body, {colors: true})); console.log('PUT', util.inspect(req.body, { colors: true }));
var index = TODOS.indexOf(req.todo); var index = TODOS.indexOf(req.todo);
var todo = TODOS[index] = req.body; var todo = TODOS[index] = req.body;

View File

@@ -33,7 +33,7 @@ export function getResponse() {
export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE'; export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
@NgModule({ @NgModule({
bootstrap: [ AppComponent ], bootstrap: [AppComponent],
imports: [ imports: [
// MaterialModule.forRoot() should be included first // MaterialModule.forRoot() should be included first
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included

View File

@@ -1,5 +1,6 @@
<!doctype html> <!doctype html>
<html> <html>
<head> <head>
<title>DSpace</title> <title>DSpace</title>
<meta charset="UTF-8"> <meta charset="UTF-8">
@@ -10,6 +11,7 @@
<base href="/"> <base href="/">
</head> </head>
<body> <body>
<ds-app> <ds-app>
@@ -18,4 +20,5 @@
<script async src="/main.bundle.js"></script> <script async src="/main.bundle.js"></script>
</body> </body>
</html> </html>

View File

@@ -25,7 +25,7 @@ export function getResponse() {
export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE'; export const UNIVERSAL_KEY = 'UNIVERSAL_CACHE';
@NgModule({ @NgModule({
bootstrap: [ AppComponent ], bootstrap: [AppComponent],
imports: [ imports: [
// MaterialModule.forRoot() should be included first // MaterialModule.forRoot() should be included first
UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included UniversalModule, // BrowserModule, HttpModule, and JsonpModule are included
@@ -63,9 +63,9 @@ export class MainModule {
universalCache[CacheService.KEY] = JSON.stringify(this.cache.dehydrate()); universalCache[CacheService.KEY] = JSON.stringify(this.cache.dehydrate());
} }
/** /**
* Clear the cache after it's rendered * Clear the cache after it's rendered
*/ */
universalAfterDehydrate = () => { universalAfterDehydrate = () => {
// comment out if LRU provided at platform level to be shared between each user // comment out if LRU provided at platform level to be shared between each user
this.cache.clear(); this.cache.clear();

View File

@@ -55,11 +55,11 @@ app.set('json spaces', 2);
app.use(cookieParser('Angular 2 Universal')); app.use(cookieParser('Angular 2 Universal'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(interceptor((req, res)=>({ app.use(interceptor((req, res) => ({
// don't compress responses with this request header // don't compress responses with this request header
isInterceptable: () => (!req.headers['x-no-compression']), isInterceptable: () => (!req.headers['x-no-compression']),
intercept: ( body, send ) => { intercept: (body, send) => {
const encodings = new Set(accepts(req).encodings()); const encodings = new Set(accepts(req).encodings());
const bodyBuffer = new Buffer(body); const bodyBuffer = new Buffer(body);
// url specific key for response cache // url specific key for response cache
const key = '__response__' + req.originalUrl || req.url; const key = '__response__' + req.originalUrl || req.url;
@@ -71,12 +71,12 @@ app.use(interceptor((req, res)=>({
// brotli // brotli
res.setHeader('Content-Encoding', 'br'); res.setHeader('Content-Encoding', 'br');
output = compressSync(bodyBuffer); output = compressSync(bodyBuffer);
mcache.put(key, {output, encoding: 'br'}); mcache.put(key, { output, encoding: 'br' });
} else if (encodings.has('gzip')) { } else if (encodings.has('gzip')) {
// gzip // gzip
res.setHeader('Content-Encoding', 'gzip'); res.setHeader('Content-Encoding', 'gzip');
output = gzipSync(bodyBuffer); output = gzipSync(bodyBuffer);
mcache.put(key, {output, encoding: 'gzip'}); mcache.put(key, { output, encoding: 'gzip' });
} }
} else { } else {
const { output, encoding } = mcache.get(key); const { output, encoding } = mcache.get(key);
@@ -87,7 +87,7 @@ app.use(interceptor((req, res)=>({
} }
}))); })));
const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', {flags: 'a'}) const accessLogStream = fs.createWriteStream(ROOT + '/morgan.log', { flags: 'a' })
app.use(morgan('common', { app.use(morgan('common', {
skip: (req, res) => res.statusCode < 400, skip: (req, res) => res.statusCode < 400,
@@ -100,8 +100,8 @@ function cacheControl(req, res, next) {
next(); next();
} }
// Serve static files // Serve static files
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30})); app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false})); app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
// //
///////////////////////// /////////////////////////
@@ -120,7 +120,7 @@ function ngApp(req, res) {
preboot: false, preboot: false,
baseUrl: '/', baseUrl: '/',
requestUrl: req.originalUrl, requestUrl: req.originalUrl,
originUrl: `http://localhost:${ app.get('port') }` originUrl: `http://localhost:${app.get('port')}`
}); });
} }

View File

@@ -57,8 +57,8 @@ function cacheControl(req, res, next) {
next(); next();
} }
// Serve static files // Serve static files
app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), {maxAge: 30})); app.use('/assets', cacheControl, express.static(path.join(__dirname, 'assets'), { maxAge: 30 }));
app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), {index: false})); app.use(cacheControl, express.static(path.join(ROOT, 'dist/client'), { index: false }));
// //
///////////////////////// /////////////////////////
@@ -77,7 +77,7 @@ function ngApp(req, res) {
preboot: false, preboot: false,
baseUrl: '/', baseUrl: '/',
requestUrl: req.originalUrl, requestUrl: req.originalUrl,
originUrl: `http://localhost:${ app.get('port') }` originUrl: `http://localhost:${app.get('port')}`
}); });
} }

8
src/typings.d.ts vendored
View File

@@ -39,7 +39,7 @@ interface SystemJS {
// Extra variables that live on Global that will be replaced by webpack DefinePlugin // Extra variables that live on Global that will be replaced by webpack DefinePlugin
declare var ENV: string; declare var ENV: string;
declare var HMR: boolean; declare var HMR: boolean;
declare var Zone: {current: any}; declare var Zone: { current: any };
interface GlobalEnvironment { interface GlobalEnvironment {
ENV; ENV;
HMR; HMR;
@@ -68,6 +68,6 @@ interface WebpackRequire {
} }
// Extend typings // Extend typings
interface NodeRequire extends WebpackRequire {} interface NodeRequire extends WebpackRequire { }
interface NodeModule extends WebpackModule {} interface NodeModule extends WebpackModule { }
interface Global extends GlobalEnvironment {} interface Global extends GlobalEnvironment { }

View File

@@ -24,5 +24,7 @@
}, },
"compileOnSave": false, "compileOnSave": false,
"buildOnSave": false, "buildOnSave": false,
"atom": { "rewriteTsconfig": false } "atom": {
"rewriteTsconfig": false
}
} }

View File

@@ -23,5 +23,7 @@
}, },
"compileOnSave": false, "compileOnSave": false,
"buildOnSave": false, "buildOnSave": false,
"atom": { "rewriteTsconfig": false } "atom": {
"rewriteTsconfig": false
}
} }

View File

@@ -6,13 +6,13 @@
"directive-selector": [ "directive-selector": [
true, true,
"attribute", "attribute",
"dspace", "ds",
"camelCase" "camelCase"
], ],
"component-selector": [ "component-selector": [
true, true,
"element", "element",
"dspace", "ds",
"kebab-case" "kebab-case"
], ],
"use-input-property-decorator": true, "use-input-property-decorator": true,
@@ -27,7 +27,7 @@
"pipe-naming": [ "pipe-naming": [
true, true,
"camelCase", "camelCase",
"dspace" "ds"
], ],
"component-class-suffix": true, "component-class-suffix": true,
"directive-class-suffix": true, "directive-class-suffix": true,

View File

@@ -4,7 +4,7 @@ const clone = require('js.clone');
const webpackMerge = require('webpack-merge'); const webpackMerge = require('webpack-merge');
const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin'); const V8LazyParseWebpackPlugin = require('v8-lazy-parse-webpack-plugin');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
import webpackConfig, { root, includeClientPackages } from './webpack.config'; import webpackConfig, { root, includeClientPackages } from './webpack.config';
// const CompressionPlugin = require('compression-webpack-plugin'); // const CompressionPlugin = require('compression-webpack-plugin');
@@ -171,8 +171,8 @@ export const serverConfig = {
export default [ export default [
// Client // Client
webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, {plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }), webpackMerge(webpackConfig[0], clone(commonConfig), clientConfig, { plugins: webpackConfig[0].plugins.concat(commonPlugins, clientPlugins) }),
// Server // Server
webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, {plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) }) webpackMerge(webpackConfig[1], clone(commonConfig), serverConfig, { plugins: webpackConfig[1].plugins.concat(commonPlugins, serverPlugins) })
]; ];