Skip to content

Instantly share code, notes, and snippets.

@sjmiles
Last active June 7, 2018 00:55
Show Gist options
  • Save sjmiles/f14ec792b9766fbb04ff to your computer and use it in GitHub Desktop.
Save sjmiles/f14ec792b9766fbb04ff to your computer and use it in GitHub Desktop.
Polymer Magic Server [DRAFT]

Polygit

Polygit is deprecated and only compatible with Bower and Polymer 1.0 & Polymer 2.0. As an alternative, use this Glitch to load dependencies via Bower.

Polygit serves files directly from github (via cdn.rawgit.com) in a manner that is compatible with HTML Imports natural deduplication feature.

Examples:

Load polymer from master branch (full debug mode)

<base href="http://polygit.org/polymer+:master/components/">

<link href="polymer/polymer.html" rel="import">

Load polymer v1.0.3, load latest release of vellum-* from sjmiles org

<base href="http://polygit.org/polymer+v1.0.3/vellum-*+sjmiles+*/components/">

<link href="polymer/polymer.html" rel="import">
<link href="vellum-grid/vellum-grid.html" rel="import">

Features:

  • stateless, stores nothing
  • maintenance free (modulo GitHub API access limits)
  • only serves files from cdn.rawgit.com

Constraints:

  • configuration must be embedded in all request URLs
  • does no dependency resolution, user configuration is absolute
  • only serves files from cdn.rawgit.com

This implementation uses a fat URL scheme, where the user configuration is contained entirely in each URL (making the URLs potentially quite long). Other implementations may be possible using cookies or other schemes to eliminate the need for fat URLs.

This server concept is primarily for hit-and-run testing, jsbins, etc. The performance is less than ideal and there is very little error reporting or other niceties.

Basic Usage

<server-name>/[<configurations>/]components/<component>/<path>

Currently a server is stood up on app-engine at polymer-magic-server.appspot.com, which is aliased as polygit.org. components is literal. <component>/<path> is the canonical path to a component resource.

Example using defaults (no <configurations>):

<link href="http://polygit.org/components/polymer/polymer.html" rel="import">

Because the URL quickly becomes unwieldy, using <base> tag is recommended.

<base href="http://polygit.org/components/">

<link href="polymer/polymer.html" rel="import">

http://jsbin.com/wihame/edit?html,output

Default Configuration

Default configuration is to use serve the latest release version for each component. An organization is automatically selected for polymer, webcomponents*, google-* components. All other components are assumed to be PolymerElements.

Custom Configurations

<configurations> are a series of configuration directives <config1>[/<config2>...].

Each <config> looks like <component>[+<org>]+<ver>|:<branch>|*.

:<branch> means pull from latest SHA on <branch>. * means pull latest release.

Examples,

Pull polymer from default org, master branch: polymer+:master Pull super-gif from sjmiles org, latest release: super-gif+sjmiles+* Pull paper-button from default org, v1.0.2 release: paper-button+v1.0.2

Note: if <org> is specified, do not forget to also include version information (+<ver>|:<branch>|*).

Wilcards are supported in component

Pull all super- elements from sjmiles org: super*+sjmiles

Example base URL with multiple configurations

http://polygit.org/polymer+:master/super*+sjmiles+*/paper-button+v1.0.2/components/

Remember that all URLs hitting the magic server must contain the complete configuration.

@timeu
Copy link

timeu commented Jul 22, 2015

Ah great thanks.
Sorry I should have read your gist more carefully. I missed the part about different organisations !

@Boo-urns
Copy link

Boo-urns commented Jun 30, 2016

Should you change the base href in the jsbin

//From
<base href="http://polymer-magic-server.appspot.com/components/">

// To Polygit
<base href="http://polygit.org/polymer+:master/components/">

@ninjachen
Copy link

Hello, I'm trying polymer at this page, but the browser warn me the resource was not found. Does the quick-tour use the wrong resource?

@herberthobregon
Copy link

404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment