Skip to content

Instantly share code, notes, and snippets.

@digilord
Last active January 4, 2016 01:48
Show Gist options
  • Save digilord/8550332 to your computer and use it in GitHub Desktop.
Save digilord/8550332 to your computer and use it in GitHub Desktop.
//Collection:
Site = new Meteor.Collection('site');
// Publication:
Meteor.publish('site', function () {
var host = headers.get(this, 'host');
return Site.find({'domain': host});
});
// helper for all templates.
Handlebars.registerHelper("site", function(){
site = Site.findOne();
theme = site.theme;
Session.set("theme", theme);
return site;
});
Handlebars.registerHelper("siteTheme", function(){
return Session.get('theme');
});
//theme = this._theme; // Help here.
//Session.set("theme", theme);
// Add theme class to html
siteTheme0 = function(){
$('html').addClass('theme0');
};
siteTheme1 = function(){
$('html').addClass('theme1');
};
siteTheme2 = function(){
$('html').addClass('theme2');
};
siteTheme3 = function(){
$('html').addClass('theme3');
};
// Change theme on change to db
Deps.autorun(function (c) {
if (Session.equals("theme", "1")){
siteTheme1();
}
else if (Session.equals("theme", "2")){
siteTheme2();
}
else if (Session.equals("theme", "3")){
siteTheme3();
}
else {
Session.set("theme", "0");
siteTheme0();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment