Skip to content

Instantly share code, notes, and snippets.

View arutnik's full-sized avatar

Andres Rutnik arutnik

View GitHub Profile
@arutnik
arutnik / about-me.component.ts
Created July 8, 2018 19:51
SEO-SPA: Meta/Title
import { Component, OnInit } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser';
//An example of a component setting title and description tags
@Component({
selector: 'app-about-me',
template: `
<p>This page is about me!</p>
`,
styleUrls: ['./about-me.component.scss']
@arutnik
arutnik / pagination-service.ts
Created July 8, 2018 19:46
SEO-SPA: Pagination service
import { Injectable, Renderer2, Inject, ElementRef } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { DOCUMENT } from "@angular/platform-browser";
//This should be injected in the app component, and any component or service
//that is responsible for pagination
@Injectable()
export class PaginationService {
private totalPages: number;
private currentPageNumber: number;
@arutnik
arutnik / bad-link.component.ts
Created July 8, 2018 19:31
SEO-SPA: Virtual Anchor
@arutnik
arutnik / package.json
Created November 5, 2017 20:20
SFA Part 6: Gulp dependencies
"gulp": "^3.9.1",
"gulp-batch": "^1.0.5",
"gulp-run": "^1.7.1",
"gulp-watch": "^4.3.11",
@arutnik
arutnik / gulpfile.js
Created November 5, 2017 20:19
SFA Part 6: Gulp serves
const gulp = require('gulp');
const run = require('gulp-run');
const watch = require('gulp-watch');
const batch = require('gulp-batch');
gulp.task('deploytosf', () => {
console.log('Running SF deploy script!')
return run('ant localDevDeploy -f salesforce/build.xml -lib salesforce/lib').exec('', function(e) {
if (!(e && e.status)) {
console.log('Page deployed!');
@arutnik
arutnik / visualforce_transform.py
Created November 5, 2017 20:17
SFA Part 5: Routing variable injection
#Only added lines shown
parser.add_argument("--pagename", help="")
pageName = args.pagename
inAppPageRoot = 'apex/' + pageName
html = html.replace('$SFPAGEROOT', "'" + inAppPageRoot + "'")
@arutnik
arutnik / index.html
Last active November 8, 2017 22:27
SFA Part 5: Deep link index
<app-root></app-root>
<script>
<!-- only added lines shown -->
gSfPageRoot = '';
if (typeof $SFPAGEROOT !== 'undefined') {
gSfPageRoot = $SFPAGEROOT;
}
function getSfPageRoot() {
return gSfPageRoot;
@arutnik
arutnik / app.component.html
Created November 5, 2017 20:12
SFA Part 4: Using static resource pipe
<!--The content below is only a placeholder and can be replaced.-->
<div style="text-align:center">
<h1>
{{title}}!
</h1>
<img [src]="'assets/salesforce.png' | staticpath">
</div>
<h2>Here are some links to help you start: </h2>
<ul>
<router-outlet></router-outlet>
@arutnik
arutnik / pipe.ts
Created November 5, 2017 20:10
SFA Part 4: Static asset pipe
declare var getSfStaticResourceRoot : () => string;
export function getStaticPathForResource(resourcePath : string) {
return getSfStaticResourceRoot() + resourcePath;
}
/*
* Ensures a static asset path gets the right prefix
*/
@Pipe({name: 'staticpath'})
@arutnik
arutnik / visualforce_transform.py
Created November 5, 2017 20:09
SFA Part 4: Injecting the controller name
#only added lines shown
parser.add_argument("--assets", help="")
args = parser.parse_args()
assetsName = args.assets
html = html.replace('#RESOURCES#', assetsName)