Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mhagmajer committed May 17, 2017
0 parents commit 58f81c9
Show file tree
Hide file tree
Showing 38 changed files with 3,746 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
definitions/*
17 changes: 17 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- # Lint configuration in YAML
extends: airbnb
parser: babel-eslint
rules:
class-methods-use-this: 0
import/extensions: 0
import/no-extraneous-dependencies: 0
import/no-unresolved: 0
import/prefer-default-export: 0
no-underscore-dangle:
- error
- allowAfterThis: true
no-use-before-define: 0
globals:
_: false
$PropertyType: false
InjectData: false
10 changes: 10 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[ignore]
.*/node_modules/.*

[include]

[libs]
definitions

[options]
suppress_comment=\\(.\\|\n\\)*\\$ExpectError
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.npm
node_modules
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Marcin Hagmajer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# mhagmajer:server-router
Server router with authentication for Meteor

# Installing

`meteor add mhagmajer:server-router`
6 changes: 6 additions & 0 deletions definitions-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* @flow */

import { ServerRouterClient } from 'meteor/mhagmajer:server-router';

// $ExpectError
(new ServerRouterClient()).sayHello();
36 changes: 36 additions & 0 deletions definitions/dependencies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
declare module invariant {
declare module.exports: any;
}

declare module 'meteor/ejson' {
declare module.exports: any;
}

declare module 'meteor/meteor' {
declare module.exports: any;
}

declare module 'meteor/random' {
declare module.exports: any;
}

declare module 'meteor/tinytest' {
declare module.exports: any;
}

declare module 'path-to-regexp' {
declare module.exports: any;
}

declare module 'query-string' {
declare module.exports: any;
}

declare module 'url-parse' {
declare module.exports: any;
}

declare var _: Object;
declare var InjectData: Object;
declare var Npm: Object;
declare var Package: Object;
60 changes: 60 additions & 0 deletions definitions/flow_v0.46.x/mhagmajer:server-router_v1.x.x.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/* @flow */

declare module 'meteor/mhagmajer:server-router' {
declare type Path = {|
path: string,
options?: {|
sensitive?: boolean,
strict?: boolean,
end?: boolean,
delimiter?: string,
|},
args: ArgsMapper,
route: Route,
|};

declare type ArgsMapper = (
params: { [key: string]: string | Array<string> },
query: { [key: string]: string }
) => Array<any>;

declare type Route = (...args: Array<any>) => Promise<void | null | string | Buffer>;

declare type Routes = { [name: string]: Route | Routes }

declare export type ServerRouterContext = {
req: http$IncomingMessage,
res: http$ServerResponse,
userId: ?string,
};

declare export class ServerRouter {
constructor(options: {|
routes: Routes,
defaultRoutePath?: string,
paths: Array<Path>,
|}): this;

addPath(data: Path): void;
addPaths(data: Array<Path>): void;
addRoutes(routes: Routes): void;
middleware: (req: http$IncomingMessage, res: http$ServerResponse, next: (error?: any) => void) => void;
}

declare export class AuthenticationRequiredError {
}

declare export class ServerRouterClient<R: Routes> {
constructor(options: {|
routes: R,
defaultRoutePath?: string,
|}): this;

redirectTo(href: string): Promise<void>;
getRouteUrl(name: string, ...args: Array<any>): string;
redirectToRoute(name: string, ...args: Array<any>): Promise<void>;

url: R;
redirect: R;
}
}
198 changes: 198 additions & 0 deletions docs/assets/anchor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
/*!
* AnchorJS - v1.2.1 - 2015-07-02
* https://github.com/bryanbraun/anchorjs
* Copyright (c) 2015 Bryan Braun; Licensed MIT
*/

function AnchorJS(options) {
'use strict';
this.options = options || {};

this._applyRemainingDefaultOptions = function(opts) {
this.options.icon = this.options.hasOwnProperty('icon')
? opts.icon
: '\ue9cb'; // Accepts characters (and also URLs?), like '#', '¶', '❡', or '§'.
this.options.visible = this.options.hasOwnProperty('visible')
? opts.visible
: 'hover'; // Also accepts 'always'
this.options.placement = this.options.hasOwnProperty('placement')
? opts.placement
: 'right'; // Also accepts 'left'
this.options.class = this.options.hasOwnProperty('class') ? opts.class : ''; // Accepts any class name.
};

this._applyRemainingDefaultOptions(options);

this.add = function(selector) {
var elements,
elsWithIds,
idList,
elementID,
i,
roughText,
tidyText,
index,
count,
newTidyText,
readableID,
anchor;

this._applyRemainingDefaultOptions(this.options);

// Provide a sensible default selector, if none is given.
if (!selector) {
selector = 'h1, h2, h3, h4, h5, h6';
} else if (typeof selector !== 'string') {
throw new Error('The selector provided to AnchorJS was invalid.');
}

elements = document.querySelectorAll(selector);
if (elements.length === 0) {
return false;
}

this._addBaselineStyles();

// We produce a list of existing IDs so we don't generate a duplicate.
elsWithIds = document.querySelectorAll('[id]');
idList = [].map.call(elsWithIds, function assign(el) {
return el.id;
});

for (i = 0; i < elements.length; i++) {
if (elements[i].hasAttribute('id')) {
elementID = elements[i].getAttribute('id');
} else {
roughText = elements[i].textContent;

// Refine it so it makes a good ID. Strip out non-safe characters, replace
// spaces with hyphens, truncate to 32 characters, and make toLowerCase.
//
// Example string: // '⚡⚡⚡ Unicode icons are cool--but they definitely don't belong in a URL fragment.'
tidyText = roughText
.replace(/[^\w\s-]/gi, '') // ' Unicode icons are cool--but they definitely dont belong in a URL fragment'
.replace(/\s+/g, '-') // '-Unicode-icons-are-cool--but-they-definitely-dont-belong-in-a-URL-fragment'
.replace(/-{2,}/g, '-') // '-Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL-fragment'
.substring(0, 64) // '-Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL'
.replace(/^-+|-+$/gm, '') // 'Unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-URL'
.toLowerCase(); // 'unicode-icons-are-cool-but-they-definitely-dont-belong-in-a-url'

// Compare our generated ID to existing IDs (and increment it if needed)
// before we add it to the page.
newTidyText = tidyText;
count = 0;
do {
if (index !== undefined) {
newTidyText = tidyText + '-' + count;
}
// .indexOf is supported in IE9+.
index = idList.indexOf(newTidyText);
count += 1;
} while (index !== -1);
index = undefined;
idList.push(newTidyText);

// Assign it to our element.
// Currently the setAttribute element is only supported in IE9 and above.
elements[i].setAttribute('id', newTidyText);

elementID = newTidyText;
}

readableID = elementID.replace(/-/g, ' ');

// The following code builds the following DOM structure in a more effiecient (albeit opaque) way.
// '<a class="anchorjs-link ' + this.options.class + '" href="#' + elementID + '" aria-label="Anchor link for: ' + readableID + '" data-anchorjs-icon="' + this.options.icon + '"></a>';
anchor = document.createElement('a');
anchor.className = 'anchorjs-link ' + this.options.class;
anchor.href = '#' + elementID;
anchor.setAttribute('aria-label', 'Anchor link for: ' + readableID);
anchor.setAttribute('data-anchorjs-icon', this.options.icon);

if (this.options.visible === 'always') {
anchor.style.opacity = '1';
}

if (this.options.icon === '\ue9cb') {
anchor.style.fontFamily = 'anchorjs-icons';
anchor.style.fontStyle = 'normal';
anchor.style.fontVariant = 'normal';
anchor.style.fontWeight = 'normal';
anchor.style.lineHeight = 1;
}

if (this.options.placement === 'left') {
anchor.style.position = 'absolute';
anchor.style.marginLeft = '-1em';
anchor.style.paddingRight = '0.5em';
elements[i].insertBefore(anchor, elements[i].firstChild);
} else {
// if the option provided is `right` (or anything else).
anchor.style.paddingLeft = '0.375em';
elements[i].appendChild(anchor);
}
}

return this;
};

this.remove = function(selector) {
var domAnchor, elements = document.querySelectorAll(selector);
for (var i = 0; i < elements.length; i++) {
domAnchor = elements[i].querySelector('.anchorjs-link');
if (domAnchor) {
elements[i].removeChild(domAnchor);
}
}
return this;
};

this._addBaselineStyles = function() {
// We don't want to add global baseline styles if they've been added before.
if (document.head.querySelector('style.anchorjs') !== null) {
return;
}

var style = document.createElement('style'),
linkRule = ' .anchorjs-link {' +
' opacity: 0;' +
' text-decoration: none;' +
' -webkit-font-smoothing: antialiased;' +
' -moz-osx-font-smoothing: grayscale;' +
' }',
hoverRule = ' *:hover > .anchorjs-link,' +
' .anchorjs-link:focus {' +
' opacity: 1;' +
' }',
anchorjsLinkFontFace = ' @font-face {' +
' font-family: "anchorjs-icons";' +
' font-style: normal;' +
' font-weight: normal;' + // Icon from icomoon; 10px wide & 10px tall; 2 empty below & 4 above
' src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBTUAAAC8AAAAYGNtYXAWi9QdAAABHAAAAFRnYXNwAAAAEAAAAXAAAAAIZ2x5Zgq29TcAAAF4AAABNGhlYWQEZM3pAAACrAAAADZoaGVhBhUDxgAAAuQAAAAkaG10eASAADEAAAMIAAAAFGxvY2EAKACuAAADHAAAAAxtYXhwAAgAVwAAAygAAAAgbmFtZQ5yJ3cAAANIAAAB2nBvc3QAAwAAAAAFJAAAACAAAwJAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAA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lvbiAxLjAAVgBlAHIAcwBpAG8AbgAgADEALgAwYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzUmVndWxhcgBSAGUAZwB1AGwAYQByYW5jaG9yanMtaWNvbnMAYQBuAGMAaABvAHIAagBzAC0AaQBjAG8AbgBzRm9udCBnZW5lcmF0ZWQgYnkgSWNvTW9vbi4ARgBvAG4AdAAgAGcAZQBuAGUAcgBhAHQAZQBkACAAYgB5ACAASQBjAG8ATQBvAG8AbgAuAAAAAwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==) format("truetype");' +
' }',
pseudoElContent = ' [data-anchorjs-icon]::after {' +
' content: attr(data-anchorjs-icon);' +
' }',
firstStyleEl;

style.className = 'anchorjs';
style.appendChild(document.createTextNode('')); // Necessary for Webkit.

// We place it in the head with the other style tags, if possible, so as to
// not look out of place. We insert before the others so these styles can be
// overridden if necessary.
firstStyleEl = document.head.querySelector('[rel="stylesheet"], style');
if (firstStyleEl === undefined) {
document.head.appendChild(style);
} else {
document.head.insertBefore(style, firstStyleEl);
}

style.sheet.insertRule(linkRule, style.sheet.cssRules.length);
style.sheet.insertRule(hoverRule, style.sheet.cssRules.length);
style.sheet.insertRule(pseudoElContent, style.sheet.cssRules.length);
style.sheet.insertRule(anchorjsLinkFontFace, style.sheet.cssRules.length);
};
}

var anchors = new AnchorJS();
12 changes: 12 additions & 0 deletions docs/assets/bass-addons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.input {
font-family: inherit;
display: block;
width: 100%;
height: 2rem;
padding: .5rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
font-size: .875rem;
border-radius: 3px;
box-sizing: border-box;
}
Loading

0 comments on commit 58f81c9

Please sign in to comment.