Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion projects/sampleBlog/src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<header>
<h1>Scully demo blog app!</h1>
<h1>Scully demo blog app! <small>{{currentState}}</small></h1>
<a [routerLink]="['/home']">🏠</a>
</header>

Expand Down
8 changes: 6 additions & 2 deletions projects/sampleBlog/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {Component} from '@angular/core';
import { IdleMonitorService } from '@scullyio/ng-lib';
import {IdleMonitorService, isScullyGenerated, isScullyRunning} from '@scullyio/ng-lib';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {
title = 'sampleBlog';
currentState = isScullyRunning()
? 'rendering inside scully'
: isScullyGenerated()
? 'Loaded from static HTML'
: 'SPA mode';
constructor(private idle: IdleMonitorService) {}
}
2 changes: 1 addition & 1 deletion projects/scullyio/ng-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@scullyio/ng-lib",
"version": "0.0.5",
"version": "0.0.6",
"repository": {
"type": "GIT",
"url": "https://github.com/scullyio/scully/tree/master/projects/scullyio/ng-lib"
Expand Down
3 changes: 3 additions & 0 deletions projects/scullyio/ng-lib/src/lib/utils/isScully.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// tslint:disable: no-string-literal
export const isScullyRunning = () => window && window['ScullyIO'] === 'running';
export const isScullyGenerated = () => window && window['ScullyIO'] === 'generated';
3 changes: 2 additions & 1 deletion projects/scullyio/ng-lib/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
export * from './lib/components.module';
export * from './lib/idleMonitor/idle-monitor.service';
export * from './lib/route-service/scully-routes.service';
export * from './lib/scully-content/scully-content.component'
export * from './lib/scully-content/scully-content.component';
export * from './lib/utils/isScully'

10 changes: 8 additions & 2 deletions scully/renderPlugins/puppeteerRenderPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable: no-string-literal
// const puppeteer = require('puppeteer');
import {Browser, Page} from 'puppeteer';
import {HandledRoute} from '../routerPlugins/addOptionalRoutesPlugin';
Expand Down Expand Up @@ -26,16 +27,21 @@ export const puppeteerRender = async (route: HandledRoute): Promise<string> => {

/** Inject this into the running page, runs in browser*/
await page.evaluateOnNewDocument(() => {
/** set "running" mode */
window['ScullyIO'] = 'running';
window.addEventListener('AngularReady', () => {
// setTimeout(() => window['onCustomEvent'](),10000);
/** add a small script tag to set "generated" mode */
const d = document.createElement('script');
d.innerHTML = `window['ScullyIO']='generated';`;
document.head.appendChild(d);
window['onCustomEvent']();
});
});

// enter url in page
await page.goto(path);

await Promise.race([pageReady, waitForIt(25 * 1000)] );
await Promise.race([pageReady, waitForIt(25 * 1000)]);

/**
* The stange notation is needed bcs typescript messes
Expand Down
2 changes: 1 addition & 1 deletion scully/utils/validateConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export async function validateConfig(config: ScullyConfig) {
})
);
} else {
logWarn('No routes defined in "scully.config"');
logWarn('No routes defined in "scully.config.js "');
}
if (hasErrors) {
/** stop everything if there are errors in the config. */
Expand Down