Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Migration to Maki 0.3 #133

Open
wants to merge 61 commits into
base: community
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
9850d89
fix slack badge
martindale Dec 29, 2015
16ca778
License Maki under the standard MIT license.
martindale Jan 6, 2016
6bd56b2
Fix circular dependency issue with OPTIONS requests.
martindale Jan 20, 2016
5ba3a04
Merge pull request #111 from martindale/options-requests
melnx Jan 21, 2016
e5e8a70
Initial working prototype for components.
martindale Jan 31, 2016
6c68179
Working Polymer components.
martindale Feb 1, 2016
5a8f774
Add page.jade
martindale Feb 4, 2016
56ab44d
Merge branch 'better-splash' into polymer-port
martindale Feb 4, 2016
06c27a4
Consolidate all work into Components.
martindale Feb 5, 2016
6a198fd
Bump version number.
martindale Feb 5, 2016
b28010f
Uglify Page.js
martindale Feb 5, 2016
69ae21e
Fix tests for now working plugins. :)
martindale Feb 5, 2016
df4efa2
Working messaging with server.
martindale Feb 6, 2016
5444312
Add client-side datastore.
martindale Feb 7, 2016
10955ba
Add missing index component.
martindale Feb 7, 2016
31ce1a8
Consolidate various scripts, stylings.
martindale Feb 7, 2016
431f4f0
Consolidate various components.
martindale Feb 8, 2016
9ff99b0
Enable support for custom indices.
martindale Feb 9, 2016
a8e6903
Improve component-ization, add support for Resource creation in plugins.
martindale Feb 10, 2016
548aaaa
Add splash file.
martindale Feb 10, 2016
3b4884c
Add all changes from melody prototyping.
martindale Feb 24, 2016
3aae398
Merge pull request #116 from martindale/melody
martindale Feb 24, 2016
6b15189
Update and internalize changes from martindale/melody#9.
martindale Feb 25, 2016
d8fcd82
Remove "internal" attribute from Index.
martindale Feb 25, 2016
d03f9dc
Make changes necessary to support Melody + Identity.
martindale Feb 29, 2016
74e9e19
Add bitcore dependencies for mnemonics.
martindale Feb 29, 2016
0fbfb72
Add all identity-related Components.
martindale Feb 29, 2016
7e17c23
Switch to minified `bitcore-mnemonic`.
martindale Feb 29, 2016
13a1634
Emit !identity when logging out.
martindale Mar 2, 2016
fcadd84
Begin to add the peer manager
martindale Mar 5, 2016
fde4afd
Import peer.js for basic implementation.
martindale Mar 5, 2016
63cd9e2
Add peerJS to the package file.
martindale Mar 5, 2016
2864d4b
Add support for populate on `create`.
martindale Mar 6, 2016
0aa9c92
Add some changes for peering.
martindale Mar 14, 2016
2ca65eb
Make single component URLs function correctly for deployed applications.
martindale Mar 14, 2016
4d62f16
Switch to `async` for most component scripts.
martindale Mar 16, 2016
b1fa022
Add new `step-ladder` component for onboarding to identity.
martindale Mar 16, 2016
89b54f9
Patch _register.
martindale Mar 22, 2016
0d130ad
Merge branch 'polymer' into peering
martindale Mar 28, 2016
dd98eec
Implement better flow for identity manager.
martindale Mar 28, 2016
073512e
Improve logout flow.
martindale Mar 28, 2016
39e55a7
Always fall back to server.
martindale Mar 29, 2016
eff184e
Always use PUT instead of POST.
martindale Mar 29, 2016
4424373
Improve code for channel, step-ladder.
martindale Mar 29, 2016
c0f9ede
Switch to POST instead of PUT.
martindale Mar 31, 2016
67dce68
Add jQuery to top-level bundle.
martindale Mar 31, 2016
2fabbb1
Update to latest jQuery.
martindale Apr 1, 2016
5443cb7
Remove jQuery from bundler.
martindale Apr 1, 2016
453ef61
Add project status to README
martindale May 29, 2016
ed65290
Improve the 404 page (to become default later).
martindale May 29, 2016
821f2d7
Add better sorting to the `get` method.
martindale May 29, 2016
36abd6d
Handle patches on sockets, accept resourcemap.
martindale May 29, 2016
101814c
Add browserify-shim and upgrade understcore
martindale May 29, 2016
478f7f1
Bundle most recent changes to identity creator.
martindale Jun 2, 2016
bd3225d
Disable PATCH events from websockets.
martindale Jun 3, 2016
eea92d1
Add missing async.min.js
martindale Jun 3, 2016
020156c
Add missing "resource" component.
martindale Jun 3, 2016
e609250
Add NeDB for data storage.
martindale Jun 3, 2016
86dce3b
Add the content-store.
martindale Jun 3, 2016
6d131ff
Simple key-value store.
martindale Jun 3, 2016
c99eae0
Merge pull request #124 from martindale/reconcile
martindale Sep 21, 2016
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 LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Eric Martindale
Copyright (c) 2016 Eric Martindale

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ Maki
==============
[![Build Status](https://img.shields.io/travis/martindale/maki.svg?branch=master&style=flat-square)](https://travis-ci.org/martindale/maki)
[![Coverage Status](https://img.shields.io/coveralls/martindale/maki.svg?style=flat-square)](https://coveralls.io/r/martindale/maki)
[![Community](https://community.ericmartindale.com/badge.svg)](https://community.ericmartindale.com/)
![Project Status](https://img.shields.io/badge/status-alpha-red.svg?style=flat-square)
[![Community](https://chat.maki.io/badge.svg)](https://chat.maki.io/)

The complete stack for building extensible apps, faster than ever. Hand-roll your application by telling Maki what your application does, and it takes care of the rest – without getting in your way if you want to customize it.

Expand Down
17 changes: 17 additions & 0 deletions components/404.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
dom-module#maki-undefined
template
.ui.text.container
h1 Nothing known.
p We're sorry, but we don't know anything about that. Here are some alternative resources you might be interested in.

.ui.horizontal.segments
.ui.segment
p One
.ui.segment
p Two
.ui.segment
p Two
script.
Polymer({
is: 'maki-undefined'
});
169 changes: 169 additions & 0 deletions components/application.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
dom-module#maki-application
style.
#navigation {
width: 100%;
}

template
maki-datastore(name="#{config.service.namespace}")
maki-channel(autoconnect, reconnect="true")

.pusher
.ui.inverted.vertical.center.aligned.segment
.ui.container
maki-navbar

.content(for="viewport")
maki-index

.ui.inverted.vertical.footer.segment
.ui.container
.ui.stackable.inverted.divided.equal.height.stackable.grid
.six.wide.column
h4.ui.inverted.header About
p This website is powered by Maki, a full-stack framework that implements strong-typing at the network level. You can see and engage with <a href="/api">the auto-generated API</a> to learn more.
p Maki is a labor of love, a result of several years of iterations and re-architectures in pursuit of a clean, hand-rolled framework for building clean, useful applications. We hope you like it.
//-.ui.inverted.link.list
a.item(href="#") Protocol
a.item(href="#") Whitepaper
a.item(href="#") Roadmap
a.item(href="#") Contact Us
.seven.wide.column
h4.ui.inverted.header Copyleft
p #{config.service.name} has not supplied a LICENSE file in <code>config/index.json</code>.
p Maki is copyleft, and encourages you to copy, clone, and <em>create</em>. After all, without a rich public domain, how else can we innovate? Much to our chagrin, the software itself is more formally <a href="https://github.com/martindale/maki/blob/master/LICENSE">MIT licensed</a>, while our content is licensed under <a href="http://creativecommons.org/licenses/by/4.0/">CC-BY</a>.
.three.wide.column
h4.ui.inverted.header Elsewhere
.ui.inverted.link.list
a.item(href="https://github.com/martindale/maki", rel="me")
i.icon.github
| GitHub
a.item(href="https://twitter.com/martindale", rel="me")
i.icon.twitter
| Twitter
a.item(href="https://facebook.com/eric.martindale", rel="me")
i.icon.facebook
| Facebook
//-a.item(href="#", rel="me")
i.icon.medium
| Medium

script(src="/js/page.min.js", async)
script(src="/js/jquery.js", async)
script.
window.maki = Polymer({
is: 'maki-application',
properties: {
src: {
type: String
},
for: {
type: String
},
route: {
type: String
},
routes: {
type: Object,
value: {}
},
components: {
type: Object,
value: {}
},
resources: {
type: Object,
observer: '_resourcesUpdated'
},
datastore: {
type: Object
},
identity: {
type: Object
},
worker: { type: Object }
},
_route: function(ctx) {
var self = this;

var component = 'maki-undefined';
for (var route in self.routes) {
var regex = self.routes[route];
var viewport = document.querySelectorAll('[for=viewport]')[0];

console.log('[MAKI:APPLICATION]', 'testing', regex, 'against', ctx.path);

if (regex.test(ctx.path)) {
console.log('[MAKI:APPLICATION]', 'picking', route, 'from', ctx.path);
component = self.components[route];
view = document.createElement(component);
view.type = self.resourceMap[route];
view.type.route = route;
break;
}
}

console.log('[MAKI:APPLICATION]', 'settled on rendering:', view.type.route, view);
//console.log('[MAKI:APPLICATION]', 'type.static:', view.type.static);
//console.log('[MAKI:APPLICATION]', 'setting and appending...');

view.setAttribute('src', ctx.path);

while (viewport.hasChildNodes()) {
viewport.removeChild(viewport.lastChild);
}
viewport.appendChild(view);
},
_resourcesUpdated: function(resources) {
var self = this;
var _route = self._route.bind(self);

self.resourceMap = {};

console.log('[MAKI:APPLICATION]', '_resourcesUpdated', resources);

var order = ['Person', 'Post', 'Index'];
Object.keys(resources).forEach(function(name) {
var resource = resources[name];
console.log('[MAKI:APPLICATION]', 'initializing', name);
['get', 'query'].forEach(function(action) {
console.log('[MAKI:APPLICATION]', 'looking for', action, 'in', resource.routes);
var route = resource.routes[action];
if (!route) return;

console.log('[MAKI:APPLICATION]', 'components are:', resource.components);

self.routes[route] = new RegExp(eval(resource.paths[action]));
self.components[route] = resource.components[action];
self.resourceMap[route] = resource;
page(route, _route);
});
});

self.routes['/'] = new RegExp(/^\/$/);
self.components['/'] = (resources.Index && resources.Index.components) ? resources.Index.components.query : 'maki-index';

page('/', _route);
page('*', _route);

page();
},
created: function() {
var self = this;

self.route = window.location.pathname;
//self.worker = new Worker('/worker.js');

$.ajax({
type: 'OPTIONS',
url: '/',
headers: {
'Accept': 'application/json'
},
success: function(data) {
self.config = data.config;
self.resources = data.resources;
}
});
}
});
127 changes: 127 additions & 0 deletions components/channel.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
dom-module#maki-channel
script(src="/js/uuid.js", async)
script(src="/js/jsonrpc.js", async)
script.
Polymer({
is: 'maki-channel',
properties: {
namespace: {
type: String
},
autoconnect: {
type: Boolean
},
reconnect: {
type: Boolean
},
subscriptions: {
type: Array
},
ws: {
type: Object
},
src: {
type: String
},
},
_send: function(method, params) {
var self = this;
self.ws.send(JSON.stringify({
'jsonrpc': '2.0',
'method': method,
'params': params,
'id': uuid.v4() // TODO: sequence?
}));
},
_subscribe: function(path) {
console.log('[MAKI:CHANNEL]', 'subscribing to:', path);
var self = this;
self._send('subscribe', {
channel: path
});
},
_consume: function() {
var self = this;
var elements = document.querySelectorAll('[src]');

console.log('[MAKI:CHANNEL]', '_consume', elements);

for (var i = 0; i < elements.length; i++) {
var element = elements[i];
self._subscribe(element.src);
}
},
_handleMessage: function(msg) {
var self = this;
console.log('[MAKI:CHANNEL]', '_handleMessage', msg);

try {
var data = JSON.parse( msg.data );
} catch (e) {
var data = {};
}

console.log('[MAKI:CHANNEL]', '_handleMessage', 'resulting data:', data);

// experimental JSON-RPC implementation
if (data.jsonrpc === '2.0') {
console.log('[MAKI:CHANNEL]', '_handleMessage', 'valid jsonrpc!');

switch (data.method) {
case 'ping':
console.log('[MAKI:CHANNEL]', 'received ping. playing pong...');
self.ws.send(JSON.stringify({
'jsonrpc': '2.0',
'result': 'pong',
'id': data.id
}));
break;
case 'patch':
// TODO: update in-memory data (two-way binding);
console.log('[MAKI:CHANNEL]', 'received `patch` event:', data.params.channel , data );
var channel = data.params.channel;
var ops = data.params.ops;
var datastore = document.querySelector('maki-datastore[name='+self.namespace+']');
var manager = document.querySelector('maki-peer-manager');

datastore._patch(channel, ops);
manager._relay(data);

break;
default:
console.error('[MAKI:CHANNEL]', 'unhandled jsonrpc method ' , data.method);
break;
}
} else {

}
},
_connect: function() {
var self = this;
var maki = document.querySelector('maki-application');
var protocol = (document.location.protocol === 'http:') ? 'ws://' : 'wss://';
var path = protocol + document.location.host; // + self.src;

console.log('[MAKI:CHANNEL]', 'websocket connecting to: ', path);

self.ws = new WebSocket(path);
self.ws.onclose = function onClose() {
if (self.reconnect === true) {
setTimeout(function() {
self._connect();
}, 500);
}
}
self.ws.onmessage = self._handleMessage.bind(self);
self.ws.onopen = function onOpen() {
console.log('[MAKI:CHANNEL]', 'websocket open.');
}
},
ready: function() {
var self = this;
console.log('[MAKI:CHANNEL]', 'ready');
if (self.autoconnect === true) {
self._connect();
}
},
});
Loading