Skip to content

Commit

Permalink
madewith WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
debergalis committed Apr 20, 2012
1 parent 387f45c commit 0a7a51d
Show file tree
Hide file tree
Showing 6 changed files with 122 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/livedata/livedata_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ _.extend(Meteor._LivedataServer.prototype, {
var invocation = new Meteor._MethodInvocation(false /* is_simulation */);
try {
var ret = Meteor._CurrentInvocation.withValue(invocation, function () {
return handler.apply(invocation, args)
return handler.apply(invocation, args);
});
} catch (e) {
var exception = e;
Expand Down
48 changes: 48 additions & 0 deletions packages/madewith/madewith.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* CSS declarations go here */
a.madewith_link {
text-decoration: none;
}

.madewith_badge {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
position: fixed;
top: 0;
right: 0;
width: 300px;
height: 129px;
background-size: 300px 129px;
text-shadow: 1px 1px black, 1px -1px black, -1px 1px black, -1px -1px black;
border: 1px solid black;
}

.madewith_badge_inner {
margin: 10px;
height: 109px;
background-color: rgba(0, 0, 0, 0.3);
position: relative;
}

.madewith_text {
position: absolute;
top: 15px;
width: 280px;
text-align: center;
color: white;
font-weight: 700;
font-size: 1.9em;
}

.madewith_votes {
position: absolute;
bottom: 15px;
width: 280px;
color: white;
font-size: 1.5em;
text-align: center;
}

.madewith_upvote {
color: yellow;
cursor: pointer;
}

17 changes: 17 additions & 0 deletions packages/madewith/madewith.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<body>
{{> madewith}}
</body>

<template name="madewith">
<a class="madewith_link" href="http://madewith.meteor.com/{{shortname}}" target="_blank">
<div class="madewith_badge">
<div class="madewith_badge_inner">
<div class="madewith_text">Made with Meteor</div>
<div class="madewith_votes">
<span class="madewith_upvote"></span>
<span class="madewith_vote_count">{{vote_count}} points</span>
</div>
</div>
</div>
</a>
</template>
41 changes: 41 additions & 0 deletions packages/madewith/madewith.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
(function () {
// automatically capture this app's hostname
var hostname = window.location.host;
var match = hostname.match(/(.*)\.meteor.com$/);
var shortname = match ? match[1] : hostname;

// connect to madewith and subscribe to my app's record
var server = Meteor.connect("http://localhost:3000/sockjs");
var sub = server.subscribe("my_app", hostname);

// minimongo collection to hold my singleton app record.
var apps = new Meteor.Collection('apps', server);

server.methods({
vote: function (hostname) {
apps.update({name: hostname}, {$inc: {vote_count: 1}});
}
});

Template.madewith.vote_count = function() {
var app = apps.findOne();
return app ? app.vote_count : '';
};

Template.madewith.shortname = function () {
return shortname;
};

Template.madewith.events = {
'click .madewith_upvote': function(event) {
var app = apps.findOne();
if (app) {
server.call('vote', hostname);
// stop these so you don't click through the link to go to the
// app.
event.stopPropagation();
event.preventDefault();
}
}
};
})();
2 changes: 2 additions & 0 deletions packages/madewith/madewith_badge.css

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions packages/madewith/package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Package.describe({
summary: "Made With Meteor badge"
});

Package.on_use(function (api) {
api.use(['livedata', 'underscore', 'liveui', 'templating'], 'client');

api.add_files([
'madewith.css',
'madewith_badge.css',
'madewith.html',
'madewith.js'], 'client');
});

0 comments on commit 0a7a51d

Please sign in to comment.