Skip to content

Commit

Permalink
Proof of concept of Sandstorm support
Browse files Browse the repository at this point in the history
  • Loading branch information
mquandalle committed Jan 2, 2015
1 parent 9b398bc commit df16424
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 21 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@

private/conf.js
private/production.js
.meteor-spk
1 change: 1 addition & 0 deletions .meteor/packages
Expand Up @@ -15,3 +15,4 @@ linto:jquery-ui
copleykj:livestamp
ongoworks:speakingurl
yasaricli:slugify
kenton:accounts-sandstorm
1 change: 1 addition & 0 deletions .meteor/versions
Expand Up @@ -33,6 +33,7 @@ iron:router@1.0.6
iron:url@1.0.6
jquery@1.0.2
json@1.0.2
kenton:accounts-sandstorm@0.1.2
launch-screen@1.0.1
less@1.0.12
linto:jquery-ui@1.11.2
Expand Down
3 changes: 2 additions & 1 deletion client/lib/utils.js
Expand Up @@ -45,7 +45,8 @@ Utils = {
resizeHeight: function(selector, callback) {
return function() {
var board = jQuery(selector);
board.height($(window).height() - 100);
var headerSize = isSandstorm ? 0 : 40;
board.height($(window).height() - 60 - headerSize);

// call
callback && callback();
Expand Down
16 changes: 16 additions & 0 deletions client/sandstorm.js
@@ -0,0 +1,16 @@
// Sandstorm support is a proof of concept only
isSandstorm = Meteor.settings && Meteor.settings.public && Meteor.settings.public.sandstorm;

if (isSandstorm) {
Meteor.subscribe('boards', function() {
var board = Boards.findOne()
Router.go("Board", {
boardId: board._id,
slug: board.slug
});
})
}

Blaze.registerHelper("isSandstorm", function() {
return isSandstorm;
});
16 changes: 9 additions & 7 deletions client/views/boards/templates.html
Expand Up @@ -29,13 +29,15 @@ <h3>My Boards</h3>
<span class="board-header-btn-text"> {{ board.title }} </span>
</a>
<div class="board-header-btns left">
<a href="#" class="board-header-btn js-star-board {{#if isStarred }}board-header-btn-enabled{{/ if }}" title="Click to star or unstar this board. Starred boards show up at the top of your boards list.">
<span class="board-header-btn-icon icon-sm icon-star"></span>
</a>
<a href="#" class="board-header-btn perms-btn js-change-vis {{ isMemberAdmin '' 'no-edit' }}" id="permission-level" popoffset='boardPermission'>
<span class="board-header-btn-icon icon-sm icon-{{ toLowerCase board.permission }}"></span>
<span class="board-header-btn-text">{{ board.permission }}</span>
</a>
{{# unless isSandstorm }}
<a href="#" class="board-header-btn js-star-board {{#if isStarred }}board-header-btn-enabled{{/ if }}" title="Click to star or unstar this board. Starred boards show up at the top of your boards list.">
<span class="board-header-btn-icon icon-sm icon-star"></span>
</a>
<a href="#" class="board-header-btn perms-btn js-change-vis {{ isMemberAdmin '' 'no-edit' }}" id="permission-level" popoffset='boardPermission'>
<span class="board-header-btn-icon icon-sm icon-{{ toLowerCase board.permission }}"></span>
<span class="board-header-btn-text">{{ board.permission }}</span>
</a>
{{/ unless }}
</div>
</div>
{{ > boardWidgets board=board }}
Expand Down
2 changes: 1 addition & 1 deletion client/views/main/routers.js
Expand Up @@ -20,7 +20,7 @@ Router.configure({
// authenticated
if (!Meteor.user() && authenticate) {

// redirect
// redirect
this.redirect(authenticate);

// options authenticate not next().
Expand Down
20 changes: 11 additions & 9 deletions client/views/main/templates.html
Expand Up @@ -41,16 +41,18 @@
<template name='AuthLayout'>
<div id="surface">
{{# if session 'pop' }}{{ > pop }}{{/if}}
<div id="header">
<div class="header-boards-button">
<a class="header-btn header-boards js-boards-menu" title="View list of boards" href="{{ pathFor route='Boards' }}">
<span class="header-btn-icon icon-lg icon-board light"></span>
<span class="header-btn-text">Boards</span>
</a>
{{# unless isSandstorm }}
<div id="header">
<div class="header-boards-button">
<a class="header-btn header-boards js-boards-menu" title="View list of boards" href="{{ pathFor route='Boards' }}">
<span class="header-btn-icon icon-lg icon-board light"></span>
<span class="header-btn-text">Boards</span>
</a>
</div>
{{ > search }}
{{ > memberHeader }}
</div>
{{ > search }}
{{ > memberHeader }}
</div>
{{/ unless }}
{{ > warning }}
<div id="content">
{{ > yield }}
Expand Down
6 changes: 3 additions & 3 deletions collections/boards.js
Expand Up @@ -73,7 +73,7 @@ isServer(function() {
// admin member insert
BoardMembers.insert({
boardId: doc._id,
userId: userId,
userId: doc.userId,
memberType: "admin",
approved: true
});
Expand All @@ -84,7 +84,7 @@ isServer(function() {
activityTypeId: doc._id,
activityType: "createBoard",
boardId: doc._id,
userId: userId
userId: doc.userId
});
});

Expand All @@ -93,7 +93,7 @@ isServer(function() {
type: 'member',
activityType: "addBoardMember",
boardId: doc.boardId,
userId: userId,
userId: doc.userId,
memberId: doc._id
});
});
Expand Down
8 changes: 8 additions & 0 deletions collections/users.js
Expand Up @@ -23,6 +23,14 @@ Users.before.insert(function (userId, doc) {
// connect profile.status default
doc.profile.status = 'offline';

// XXX The meteor convention for this field is `name` not `fullname`, see for instance the
// documentation: http://docs.meteor.com/#/full/meteor_users
// Third parties packages like `kenton:accounts-sandstorm` or `aldeed:simple-schema` assume
// that this convention is respected. So maybe we should rename this field?
if (! doc.profile.fullname && doc.profile.name) {
doc.profile.fullname = doc.profile.name.replace("%20", " ");
}

// slugify to username
doc.username = slugify(doc.profile.fullname, '');
});
Expand Down
61 changes: 61 additions & 0 deletions sandstorm-pkgdef.capnp
@@ -0,0 +1,61 @@
@0xb49ebaaf160644ac;

using Spk = import "/sandstorm/package.capnp";
# This imports:
# $SANDSTORM_HOME/latest/usr/include/sandstorm/package.capnp
# Check out that file to see the full, documented package definition format.

const pkgdef :Spk.PackageDefinition = (
# The package definition. Note that the spk tool looks specifically for the
# "pkgdef" constant.

id = "2ps3tfnka33nvxwjpw3nm48jyz6zwezg7ekghq3ucx3192z3sng0",
# Your app ID is actually its public key. The private key was placed in
# your keyring. All updates must be signed with the same key.

manifest = (
# This manifest is included in your app package to tell Sandstorm
# about your app.

appVersion = 0, # Increment this for every release.

actions = [
# Define your "new document" handlers here.
( title = (defaultText = "New Metrello board"),
command = .myCommand
# The command to run when starting for the first time. (".myCommand"
# is just a constant defined at the bottom of the file.)
)
],

continueCommand = .myCommand
# This is the command called to start your app back up after it has been
# shut down for inactivity. Here we're using the same command as for
# starting a new instance, but you could use different commands for each
# case.
),

sourceMap = (
# The following directories will be copied into your package.
searchPath = [
( sourcePath = ".meteor-spk/deps" ),
( sourcePath = ".meteor-spk/bundle" )
]
),

alwaysInclude = [ "." ]
# This says that we always want to include all files from the source map.
# (An alternative is to automatically detect dependencies by watching what
# the app opens while running in dev mode. To see what that looks like,
# run `spk init` without the -A option.)
);

const myCommand :Spk.Manifest.Command = (
# Here we define the command used to start up your server.
argv = ["/sandstorm-http-bridge", "4000", "--", "node", "start.js"],
environ = [
# Note that this defines the *entire* environment seen by your app.
(key = "PATH", value = "/usr/local/bin:/usr/bin:/bin"),
(key = "METEOR_SETTINGS", value = "{\"public\": {\"sandstorm\": true}}")
]
);

0 comments on commit df16424

Please sign in to comment.