mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
Settings package
This commit is contained in:
parent
a3b930012c
commit
057580b793
91 changed files with 445 additions and 385 deletions
|
@ -94,3 +94,4 @@ telescope-tagline-banner
|
||||||
# Custom Packages
|
# Custom Packages
|
||||||
telescope-seo
|
telescope-seo
|
||||||
telescope-messages
|
telescope-messages
|
||||||
|
telescope-settings
|
||||||
|
|
|
@ -134,6 +134,7 @@ telescope-releases@0.1.0
|
||||||
telescope-rss@0.0.0
|
telescope-rss@0.0.0
|
||||||
telescope-search@0.0.0
|
telescope-search@0.0.0
|
||||||
telescope-seo@0.0.5
|
telescope-seo@0.0.5
|
||||||
|
telescope-settings@0.0.0
|
||||||
telescope-singleday@0.1.0
|
telescope-singleday@0.1.0
|
||||||
telescope-subscribe-to-posts@0.1.0
|
telescope-subscribe-to-posts@0.1.0
|
||||||
telescope-tagline-banner@0.1.0
|
telescope-tagline-banner@0.1.0
|
||||||
|
|
|
@ -13,11 +13,6 @@ UI.registerHelper('eachWithRank', function(items, options) {
|
||||||
});
|
});
|
||||||
return out;
|
return out;
|
||||||
});
|
});
|
||||||
|
|
||||||
UI.registerHelper('getSetting', function(setting, defaultArgument){
|
|
||||||
setting = getSetting(setting, defaultArgument);
|
|
||||||
return setting;
|
|
||||||
});
|
|
||||||
UI.registerHelper('isLoggedIn', function() {
|
UI.registerHelper('isLoggedIn', function() {
|
||||||
return !!Meteor.user();
|
return !!Meteor.user();
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Session variables
|
// Session variables
|
||||||
Session.set('postsLimit', getSetting('postsPerPage', 10));
|
Session.set('postsLimit', Settings.get('postsPerPage', 10));
|
||||||
|
|
||||||
// Sort postModules array position using modulePositions as index
|
// Sort postModules array position using modulePositions as index
|
||||||
postModules = _.sortBy(postModules, 'order');
|
postModules = _.sortBy(postModules, 'order');
|
||||||
|
@ -12,4 +12,4 @@ Meteor.startup(function () {
|
||||||
$('#rss-link').attr('title', i18n.t('new_posts'));
|
$('#rss-link').attr('title', i18n.t('new_posts'));
|
||||||
});
|
});
|
||||||
|
|
||||||
// AutoForm.debug();
|
// AutoForm.debug();
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
<template name="settings">
|
|
||||||
{{#if this.hasSettings}}
|
|
||||||
{{> quickForm collection="Settings" id="updateSettingsForm" type="update" doc=this.settings label-class="control-label" input-col-class="controls" template="telescope"}}
|
|
||||||
{{else}}
|
|
||||||
{{> quickForm collection="Settings" id="insertSettingsForm" type="insert" template="telescope" label-class="control-label" input-col-class="controls"}}
|
|
||||||
{{/if}}
|
|
||||||
</template>
|
|
|
@ -15,21 +15,21 @@ Template[getTemplate('css')].helpers({
|
||||||
|
|
||||||
// loop over all properties, and add the relevant selectors
|
// loop over all properties, and add the relevant selectors
|
||||||
_.each(properties, function (selector, property) {
|
_.each(properties, function (selector, property) {
|
||||||
css += selector + "{\n " + property + ": " + getSetting(color) + ";\n}\n";
|
css += selector + "{\n " + property + ": " + Settings.get(color) + ";\n}\n";
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return css;
|
return css;
|
||||||
},
|
},
|
||||||
headerTextColorHalfOpacity: function () {
|
headerTextColorHalfOpacity: function () {
|
||||||
return tinycolor(getSetting("headerTextColor")).setAlpha(0.5);
|
return tinycolor(Settings.get("headerTextColor")).setAlpha(0.5);
|
||||||
},
|
},
|
||||||
buttonColorHalfOpacity: function () {
|
buttonColorHalfOpacity: function () {
|
||||||
return tinycolor(getSetting("buttonColor")).setAlpha(0.5);
|
return tinycolor(Settings.get("buttonColor")).setAlpha(0.5);
|
||||||
},
|
},
|
||||||
hideAuthClass: function () {
|
hideAuthClass: function () {
|
||||||
|
|
||||||
var authClass = '';
|
var authClass = '';
|
||||||
var authMethods = getSetting('authMethods', ["email"]);
|
var authMethods = Settings.get('authMethods', ["email"]);
|
||||||
var selectors = [
|
var selectors = [
|
||||||
{name: 'email', selector: ".at-pwd-form"},
|
{name: 'email', selector: ".at-pwd-form"},
|
||||||
{name: 'twitter', selector: "#at-twitter"},
|
{name: 'twitter', selector: "#at-twitter"},
|
||||||
|
@ -50,5 +50,5 @@ Template[getTemplate('css')].helpers({
|
||||||
|
|
||||||
return authClass.slice(0, - 2) + "{display:none !important}";
|
return authClass.slice(0, - 2) + "{display:none !important}";
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Template[getTemplate('footer')].helpers({
|
Template[getTemplate('footer')].helpers({
|
||||||
footerCode: function(){
|
footerCode: function(){
|
||||||
return getSetting('footerCode');
|
return Settings.get('footerCode');
|
||||||
},
|
},
|
||||||
footerClass: function(){
|
footerClass: function(){
|
||||||
return Session.get('isPostsList') ? 'absolute' : 'static';
|
return Session.get('isPostsList') ? 'absolute' : 'static';
|
||||||
},
|
},
|
||||||
|
@ -11,4 +11,4 @@ Template[getTemplate('footer')].helpers({
|
||||||
getTemplate: function () {
|
getTemplate: function () {
|
||||||
return getTemplate(this.template);
|
return getTemplate(this.template);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ Template[getTemplate('layout')].helpers({
|
||||||
return getTemplate('nav');
|
return getTemplate('nav');
|
||||||
},
|
},
|
||||||
navLayout: function () {
|
navLayout: function () {
|
||||||
return getSetting('navLayout', 'top-nav');
|
return Settings.get('navLayout', 'top-nav');
|
||||||
},
|
},
|
||||||
messages: function () {
|
messages: function () {
|
||||||
return getTemplate('messages');
|
return getTemplate('messages');
|
||||||
|
@ -24,7 +24,7 @@ Template[getTemplate('layout')].helpers({
|
||||||
return getTemplate('css');
|
return getTemplate('css');
|
||||||
},
|
},
|
||||||
extraCode: function() {
|
extraCode: function() {
|
||||||
return getSetting('extraCode');
|
return Settings.get('extraCode');
|
||||||
},
|
},
|
||||||
heroModules: function () {
|
heroModules: function () {
|
||||||
return _.sortBy(heroModules, 'order');
|
return _.sortBy(heroModules, 'order');
|
||||||
|
@ -48,7 +48,7 @@ Template[getTemplate('layout')].rendered = function(){
|
||||||
var link = document.createElement('link');
|
var link = document.createElement('link');
|
||||||
link.type = 'image/x-icon';
|
link.type = 'image/x-icon';
|
||||||
link.rel = 'shortcut icon';
|
link.rel = 'shortcut icon';
|
||||||
link.href = getSetting('faviconUrl', '/img/favicon.ico');
|
link.href = Settings.get('faviconUrl', '/img/favicon.ico');
|
||||||
document.getElementsByTagName('head')[0].appendChild(link);
|
document.getElementsByTagName('head')[0].appendChild(link);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -60,4 +60,4 @@ Template[getTemplate('layout')].events({
|
||||||
$('body').removeClass('mobile-nav-open');
|
$('body').removeClass('mobile-nav-open');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Template[getTemplate('no_account')].helpers({
|
Template[getTemplate('no_account')].helpers({
|
||||||
landingPageText: function(){
|
landingPageText: function(){
|
||||||
return getSetting("landingPageText");
|
return Settings.get("landingPageText");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Template[getTemplate('no_account')].events({
|
Template[getTemplate('no_account')].events({
|
||||||
|
@ -9,4 +9,4 @@ Template[getTemplate('no_account')].events({
|
||||||
Router.go('/');
|
Router.go('/');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Template[getTemplate('no_invite')].helpers({
|
Template[getTemplate('no_invite')].helpers({
|
||||||
afterSignupText: function(){
|
afterSignupText: function(){
|
||||||
return getSetting("afterSignupText");
|
return Settings.get("afterSignupText");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
Template[getTemplate('logo')].helpers({
|
Template[getTemplate('logo')].helpers({
|
||||||
site_title: function(){
|
site_title: function(){
|
||||||
return getSetting('title', "Telescope");
|
return Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
logo_url: function(){
|
logo_url: function(){
|
||||||
return getSetting('logoUrl');
|
return Settings.get('logoUrl');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Template[getTemplate('nav')].helpers({
|
Template[getTemplate('nav')].helpers({
|
||||||
headerClass: function () {
|
headerClass: function () {
|
||||||
var headerClass = "";
|
var headerClass = "";
|
||||||
var bgBrightness = tinycolor(getSetting('headerColor')).getBrightness();
|
var bgBrightness = tinycolor(Settings.get('headerColor')).getBrightness();
|
||||||
if (bgBrightness < 50) {
|
if (bgBrightness < 50) {
|
||||||
headerClass += " dark-bg";
|
headerClass += " dark-bg";
|
||||||
} else if (bgBrightness < 130) {
|
} else if (bgBrightness < 130) {
|
||||||
|
@ -33,7 +33,7 @@ Template[getTemplate('nav')].helpers({
|
||||||
if (this.length > 3) {
|
if (this.length > 3) {
|
||||||
dropdownClass += "long-dropdown";
|
dropdownClass += "long-dropdown";
|
||||||
}
|
}
|
||||||
if (getSetting('navLayout', 'top-nav') == 'top-nav' && getThemeSetting('useDropdowns', true)) {
|
if (Settings.get('navLayout', 'top-nav') == 'top-nav' && getThemeSetting('useDropdowns', true)) {
|
||||||
dropdownClass += "has-dropdown";
|
dropdownClass += "has-dropdown";
|
||||||
} else {
|
} else {
|
||||||
dropdownClass += "no-dropdown";
|
dropdownClass += "no-dropdown";
|
||||||
|
@ -61,4 +61,4 @@ Template[getTemplate('nav')].events({
|
||||||
e.stopPropagation(); // Make sure we don't immediately close the mobile nav again. See layout.js event handler.
|
e.stopPropagation(); // Make sure we don't immediately close the mobile nav again. See layout.js event handler.
|
||||||
$('body').toggleClass('mobile-nav-open');
|
$('body').toggleClass('mobile-nav-open');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,7 +8,7 @@ Template[getTemplate('userMenu')].helpers({
|
||||||
menuMode: function () {
|
menuMode: function () {
|
||||||
if (!!this.mobile) {
|
if (!!this.mobile) {
|
||||||
return 'list';
|
return 'list';
|
||||||
} else if (getSetting('navLayout', 'top-nav') === 'top-nav') {
|
} else if (Settings.get('navLayout', 'top-nav') === 'top-nav') {
|
||||||
return 'dropdown';
|
return 'dropdown';
|
||||||
} else {
|
} else {
|
||||||
return 'accordion';
|
return 'accordion';
|
||||||
|
|
|
@ -3,7 +3,7 @@ Template[getTemplate('postAdmin')].helpers({
|
||||||
return this.status == STATUS_PENDING;
|
return this.status == STATUS_PENDING;
|
||||||
},
|
},
|
||||||
showUnapprove: function(){
|
showUnapprove: function(){
|
||||||
return !!getSetting('requirePostsApproval') && this.status == STATUS_APPROVED;
|
return !!Settings.get('requirePostsApproval') && this.status == STATUS_APPROVED;
|
||||||
},
|
},
|
||||||
shortScore: function(){
|
shortScore: function(){
|
||||||
return Math.floor(this.score*1000)/1000;
|
return Math.floor(this.score*1000)/1000;
|
||||||
|
@ -14,9 +14,9 @@ Template[getTemplate('postAdmin')].events({
|
||||||
'click .approve-link': function(e, instance){
|
'click .approve-link': function(e, instance){
|
||||||
Meteor.call('approvePost', this);
|
Meteor.call('approvePost', this);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
},
|
},
|
||||||
'click .unapprove-link': function(e, instance){
|
'click .unapprove-link': function(e, instance){
|
||||||
Meteor.call('unapprovePost', this);
|
Meteor.call('unapprovePost', this);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ Template[getTemplate('posts_list')].created = function() {
|
||||||
|
|
||||||
Template[getTemplate('posts_list')].helpers({
|
Template[getTemplate('posts_list')].helpers({
|
||||||
postsLayout: function () {
|
postsLayout: function () {
|
||||||
return getSetting('postsLayout', 'posts-list');
|
return Settings.get('postsLayout', 'posts-list');
|
||||||
},
|
},
|
||||||
description: function () {
|
description: function () {
|
||||||
var controller = Iron.controller();
|
var controller = Iron.controller();
|
||||||
|
@ -40,4 +40,4 @@ Template[getTemplate('posts_list')].helpers({
|
||||||
postsListSort: function () {
|
postsListSort: function () {
|
||||||
return getTemplate('postsListSort');
|
return getTemplate('postsListSort');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
Template[getTemplate('postViewsNav')].helpers({
|
Template[getTemplate('postViewsNav')].helpers({
|
||||||
showNav: function () {
|
showNav: function () {
|
||||||
var navElements = getSetting('postViews', _.pluck(viewsMenu, 'route'));
|
var navElements = Settings.get('postViews', _.pluck(viewsMenu, 'route'));
|
||||||
var navCount = (typeof navElements === "array") ? navElements.length : _.keys(navElements).length;
|
var navCount = (typeof navElements === "array") ? navElements.length : _.keys(navElements).length;
|
||||||
return navCount > 1;
|
return navCount > 1;
|
||||||
},
|
},
|
||||||
menuItems: function () {
|
menuItems: function () {
|
||||||
var defaultViews = _.pluck(viewsMenu, 'route');
|
var defaultViews = _.pluck(viewsMenu, 'route');
|
||||||
var menuItems = _.filter(viewsMenu, function (item) {
|
var menuItems = _.filter(viewsMenu, function (item) {
|
||||||
if (!_.contains(getSetting('postViews', defaultViews), item.route) || (item.adminOnly && !isAdmin(Meteor.user()))) {
|
if (!_.contains(Settings.get('postViews', defaultViews), item.route) || (item.adminOnly && !isAdmin(Meteor.user()))) {
|
||||||
// don't show the item
|
// don't show the item
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -15,4 +15,4 @@ Template[getTemplate('postViewsNav')].helpers({
|
||||||
});
|
});
|
||||||
return menuItems;
|
return menuItems;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -226,7 +226,7 @@ Meteor.methods({
|
||||||
if (!hasAdminRights) {
|
if (!hasAdminRights) {
|
||||||
|
|
||||||
var timeSinceLastComment = timeSinceLast(user, Comments),
|
var timeSinceLastComment = timeSinceLast(user, Comments),
|
||||||
commentInterval = Math.abs(parseInt(getSetting('commentInterval',15)));
|
commentInterval = Math.abs(parseInt(Settings.get('commentInterval',15)));
|
||||||
|
|
||||||
// check that user waits more than 15 seconds between comments
|
// check that user waits more than 15 seconds between comments
|
||||||
if((timeSinceLastComment < commentInterval))
|
if((timeSinceLastComment < commentInterval))
|
||||||
|
|
|
@ -231,7 +231,7 @@ getPostProperties = function (post) {
|
||||||
// default status for new posts
|
// default status for new posts
|
||||||
getDefaultPostStatus = function (user) {
|
getDefaultPostStatus = function (user) {
|
||||||
var hasAdminRights = typeof user === 'undefined' ? false : isAdmin(user);
|
var hasAdminRights = typeof user === 'undefined' ? false : isAdmin(user);
|
||||||
if (hasAdminRights || !getSetting('requirePostsApproval', false)) {
|
if (hasAdminRights || !Settings.get('requirePostsApproval', false)) {
|
||||||
// if user is admin, or else post approval is not required
|
// if user is admin, or else post approval is not required
|
||||||
return STATUS_APPROVED
|
return STATUS_APPROVED
|
||||||
} else {
|
} else {
|
||||||
|
@ -408,8 +408,8 @@ Meteor.methods({
|
||||||
|
|
||||||
var timeSinceLastPost=timeSinceLast(user, Posts),
|
var timeSinceLastPost=timeSinceLast(user, Posts),
|
||||||
numberOfPostsInPast24Hours=numberOfItemsInPast24Hours(user, Posts),
|
numberOfPostsInPast24Hours=numberOfItemsInPast24Hours(user, Posts),
|
||||||
postInterval = Math.abs(parseInt(getSetting('postInterval', 30))),
|
postInterval = Math.abs(parseInt(Settings.get('postInterval', 30))),
|
||||||
maxPostsPer24Hours = Math.abs(parseInt(getSetting('maxPostsPerDay', 30)));
|
maxPostsPer24Hours = Math.abs(parseInt(Settings.get('maxPostsPerDay', 30)));
|
||||||
|
|
||||||
// check that user waits more than X seconds between posts
|
// check that user waits more than X seconds between posts
|
||||||
if(timeSinceLastPost < postInterval)
|
if(timeSinceLastPost < postInterval)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
analyticsInit = _.once(function() {
|
analyticsInit = _.once(function() {
|
||||||
|
|
||||||
// Mixpanel
|
// Mixpanel
|
||||||
if (mixpanelId=getSetting("mixpanelId")){
|
if (mixpanelId=Settings.get("mixpanelId")){
|
||||||
(function (c, a) {
|
(function (c, a) {
|
||||||
window.mixpanel = a;
|
window.mixpanel = a;
|
||||||
var b, d, h, e;
|
var b, d, h, e;
|
||||||
|
@ -33,7 +33,7 @@ analyticsInit = _.once(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GoSquared
|
// GoSquared
|
||||||
if (goSquaredId = getSetting("goSquaredId")) {
|
if (goSquaredId = Settings.get("goSquaredId")) {
|
||||||
window.GoSquared = {};
|
window.GoSquared = {};
|
||||||
GoSquared.acct = goSquaredId;
|
GoSquared.acct = goSquaredId;
|
||||||
window._gstc_lt = +new Date();
|
window._gstc_lt = +new Date();
|
||||||
|
@ -45,7 +45,7 @@ analyticsInit = _.once(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clicky
|
// Clicky
|
||||||
if ((clickyId = getSetting("clickyId"))){
|
if ((clickyId = Settings.get("clickyId"))){
|
||||||
clicky_site_ids = [];
|
clicky_site_ids = [];
|
||||||
clicky_site_ids.push(clickyId);
|
clicky_site_ids.push(clickyId);
|
||||||
(function() {
|
(function() {
|
||||||
|
@ -58,7 +58,7 @@ analyticsInit = _.once(function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Analytics
|
// Google Analytics
|
||||||
if (googleAnalyticsId = getSetting("googleAnalyticsId")){
|
if (googleAnalyticsId = Settings.get("googleAnalyticsId")){
|
||||||
|
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
|
@ -67,18 +67,18 @@ analyticsInit = _.once(function() {
|
||||||
|
|
||||||
ga('create', googleAnalyticsId, 'auto');
|
ga('create', googleAnalyticsId, 'auto');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
analyticsRequest = function() {
|
analyticsRequest = function() {
|
||||||
|
|
||||||
// Google Analytics
|
// Google Analytics
|
||||||
if (typeof window.ga !== 'undefined'){
|
if (typeof window.ga !== 'undefined'){
|
||||||
ga('send', 'pageview', {
|
ga('send', 'pageview', {
|
||||||
'page': window.location.pathname
|
'page': window.location.pathname
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mixpanel
|
// Mixpanel
|
||||||
if(typeof mixpanel !== 'undefined' && typeof mixpanel.people !== 'undefined'){
|
if(typeof mixpanel !== 'undefined' && typeof mixpanel.people !== 'undefined'){
|
||||||
|
@ -87,7 +87,7 @@ analyticsRequest = function() {
|
||||||
mixpanel.people.identify(currentUserEmail);
|
mixpanel.people.identify(currentUserEmail);
|
||||||
mixpanel.people.set({
|
mixpanel.people.set({
|
||||||
'username': getDisplayName(Meteor.user()),
|
'username': getDisplayName(Meteor.user()),
|
||||||
'$last_login': new Date(),
|
'$last_login': new Date(),
|
||||||
'$created': moment(Meteor.user().createdAt)._d,
|
'$created': moment(Meteor.user().createdAt)._d,
|
||||||
'$email': currentUserEmail
|
'$email': currentUserEmail
|
||||||
});
|
});
|
||||||
|
@ -110,4 +110,4 @@ analyticsRequest = function() {
|
||||||
clicky.log(encodeURIComponent(window.location.pathname), getCurrentTemplate(), "pageview");
|
clicky.log(encodeURIComponent(window.location.pathname), getCurrentTemplate(), "pageview");
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* global
|
/* global
|
||||||
AccountsTemplates: false,
|
AccountsTemplates: false,
|
||||||
getSetting: false
|
Settings: false
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
Accounts.emailTemplates.siteName = getSetting('title');
|
Accounts.emailTemplates.siteName = Settings.get('title');
|
||||||
Accounts.emailTemplates.from = getSetting('defaultEmail');
|
Accounts.emailTemplates.from = Settings.get('defaultEmail');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
clog = function (s) {
|
clog = function (s) {
|
||||||
if(getSetting('debug', false))
|
if(Settings.get('debug', false))
|
||||||
console.log(s);
|
console.log(s);
|
||||||
}
|
};
|
||||||
|
|
|
@ -102,7 +102,7 @@ getDomain = function(url){
|
||||||
return urlObject.parse(url).hostname.replace('www.', '');
|
return urlObject.parse(url).hostname.replace('www.', '');
|
||||||
};
|
};
|
||||||
invitesEnabled = function () {
|
invitesEnabled = function () {
|
||||||
return getSetting("requireViewInvite") || getSetting("requirePostInvite");
|
return Settings.get("requireViewInvite") || Settings.get("requirePostInvite");
|
||||||
};
|
};
|
||||||
getOutgoingUrl = function(url){
|
getOutgoingUrl = function(url){
|
||||||
return getRouteUrl('out', {}, {query: {url: url}});
|
return getRouteUrl('out', {}, {query: {url: url}});
|
||||||
|
|
|
@ -3,24 +3,9 @@ AdminController = RouteController.extend({
|
||||||
template: "adminWrapper"
|
template: "adminWrapper"
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.startup(function (){
|
Meteor.startup(function (){
|
||||||
|
|
||||||
// Settings
|
|
||||||
|
|
||||||
Router.route('/settings', {
|
|
||||||
controller: AdminController,
|
|
||||||
name: 'settings',
|
|
||||||
// layoutTemplate: getTemplate('adminLayout'),
|
|
||||||
data: function () {
|
|
||||||
// we only have one set of settings for now
|
|
||||||
return {
|
|
||||||
hasSettings: !!Settings.find().count(),
|
|
||||||
settings: Settings.findOne()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Loading (for testing purposes)
|
// Loading (for testing purposes)
|
||||||
|
|
||||||
Router.route('/loading', {
|
Router.route('/loading', {
|
||||||
|
@ -34,5 +19,5 @@ Meteor.startup(function (){
|
||||||
name: 'toolbox',
|
name: 'toolbox',
|
||||||
template: getTemplate('toolbox')
|
template: getTemplate('toolbox')
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -133,7 +133,7 @@ Router._filters = {
|
||||||
|
|
||||||
setTitle: function () {
|
setTitle: function () {
|
||||||
// if getTitle is set, use it. Otherwise default to site title.
|
// if getTitle is set, use it. Otherwise default to site title.
|
||||||
var title = (typeof this.getTitle === 'function') ? this.getTitle() : getSetting("title", "Telescope");
|
var title = (typeof this.getTitle === 'function') ? this.getTitle() : Settings.get("title", "Telescope");
|
||||||
document.title = title;
|
document.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ PostsListController = RouteController.extend({
|
||||||
// note: most of the time this.params.slug will be empty
|
// note: most of the time this.params.slug will be empty
|
||||||
this._terms = {
|
this._terms = {
|
||||||
view: this.view,
|
view: this.view,
|
||||||
limit: this.params.limit || getSetting('postsPerPage', 10),
|
limit: this.params.limit || Settings.get('postsPerPage', 10),
|
||||||
category: this.params.slug
|
category: this.params.slug
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ PostsListController = RouteController.extend({
|
||||||
hasMorePosts: this._terms.limit == postsCount,
|
hasMorePosts: this._terms.limit == postsCount,
|
||||||
loadMoreHandler: function () {
|
loadMoreHandler: function () {
|
||||||
|
|
||||||
var count = parseInt(Session.get('postsLimit')) + parseInt(getSetting('postsPerPage', 10));
|
var count = parseInt(Session.get('postsLimit')) + parseInt(Settings.get('postsPerPage', 10));
|
||||||
var categorySegment = Session.get('categorySlug') ? Session.get('categorySlug') + '/' : '';
|
var categorySegment = Session.get('categorySlug') ? Session.get('categorySlug') + '/' : '';
|
||||||
|
|
||||||
// TODO: use Router.path here?
|
// TODO: use Router.path here?
|
||||||
|
@ -67,12 +67,12 @@ PostsListController = RouteController.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
return i18n.t(this.view) + ' - ' + getSetting('title', "Telescope");
|
return i18n.t(this.view) + ' - ' + Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
|
|
||||||
getDescription: function () {
|
getDescription: function () {
|
||||||
if (Router.current().route.getName() == 'posts_default') { // return site description on root path
|
if (Router.current().route.getName() == 'posts_default') { // return site description on root path
|
||||||
return getSetting('description');
|
return Settings.get('description');
|
||||||
} else {
|
} else {
|
||||||
return i18n.t(_.findWhere(viewsMenu, {label: this.view}).description);
|
return i18n.t(_.findWhere(viewsMenu, {label: this.view}).description);
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ PostsListController = RouteController.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
var getDefaultViewController = function () {
|
var getDefaultViewController = function () {
|
||||||
var defaultView = getSetting('defaultView', 'top');
|
var defaultView = Settings.get('defaultView', 'top');
|
||||||
defaultView = defaultView.charAt(0).toUpperCase() + defaultView.slice(1);
|
defaultView = defaultView.charAt(0).toUpperCase() + defaultView.slice(1);
|
||||||
return eval("Posts"+defaultView+"Controller");
|
return eval("Posts"+defaultView+"Controller");
|
||||||
};
|
};
|
||||||
|
@ -96,8 +96,8 @@ Meteor.startup(function () {
|
||||||
|
|
||||||
PostsDefaultController = getDefaultViewController().extend({
|
PostsDefaultController = getDefaultViewController().extend({
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
var title = getSetting('title', 'Telescope');
|
var title = Settings.get('title', 'Telescope');
|
||||||
var tagline = getSetting('tagline');
|
var tagline = Settings.get('tagline');
|
||||||
var fullTitle = !!tagline ? title + ' – ' + tagline : title ;
|
var fullTitle = !!tagline ? title + ' – ' + tagline : title ;
|
||||||
return fullTitle;
|
return fullTitle;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ PostPageController = RouteController.extend({
|
||||||
|
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
if (!!this.post())
|
if (!!this.post())
|
||||||
return this.post().title + ' - ' + getSetting('title', "Telescope");
|
return this.post().title + ' - ' + Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
|
|
||||||
onBeforeAction: function() {
|
onBeforeAction: function() {
|
||||||
|
@ -255,4 +255,4 @@ Meteor.startup(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
var increasePostClicks = function(postId, ip){
|
var increasePostClicks = function(postId, ip){
|
||||||
|
|
||||||
var clickEvent = {
|
var clickEvent = {
|
||||||
name: 'click',
|
name: 'click',
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -53,7 +53,7 @@ Meteor.startup(function (){
|
||||||
var emailProperties = {
|
var emailProperties = {
|
||||||
profileUrl: getProfileUrl(user),
|
profileUrl: getProfileUrl(user),
|
||||||
username: getUserName(user),
|
username: getUserName(user),
|
||||||
siteTitle: getSetting('title'),
|
siteTitle: Settings.get('title'),
|
||||||
siteUrl: getSiteUrl()
|
siteUrl: getSiteUrl()
|
||||||
};
|
};
|
||||||
html = Handlebars.templates[getTemplate('emailAccountApproved')](emailProperties);
|
html = Handlebars.templates[getTemplate('emailAccountApproved')](emailProperties);
|
||||||
|
@ -62,4 +62,4 @@ Meteor.startup(function (){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,7 +7,7 @@ UserPageController = RouteController.extend({
|
||||||
coreSubscriptions.subscribe('singleUser', this.params._idOrSlug)
|
coreSubscriptions.subscribe('singleUser', this.params._idOrSlug)
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
getUser: function () {
|
getUser: function () {
|
||||||
return Meteor.users.findOne({slug: this.params._idOrSlug});
|
return Meteor.users.findOne({slug: this.params._idOrSlug});
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ UserPageController = RouteController.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
return getDisplayName(this.getUser()) + ' - ' + getSetting('title', "Telescope");
|
return getDisplayName(this.getUser()) + ' - ' + Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
|
|
||||||
getDescription: function () {
|
getDescription: function () {
|
||||||
|
@ -122,4 +122,4 @@ Meteor.startup(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -82,7 +82,7 @@ upvoteItem = function (collection, item, user) {
|
||||||
|
|
||||||
// if karma redistribution is enabled, give karma to all previous upvoters of the post
|
// if karma redistribution is enabled, give karma to all previous upvoters of the post
|
||||||
// (but not to the person doing the upvoting)
|
// (but not to the person doing the upvoting)
|
||||||
if (getSetting('redistributeKarma', false)) {
|
if (Settings.get('redistributeKarma', false)) {
|
||||||
_.each(item.upvoters, function (upvoterId) {
|
_.each(item.upvoters, function (upvoterId) {
|
||||||
// share the karma equally among all upvoters, but cap the value at 0.1
|
// share the karma equally among all upvoters, but cap the value at 0.1
|
||||||
var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length);
|
var karmaIncrease = Math.min(0.1, votePower/item.upvoters.length);
|
||||||
|
@ -122,7 +122,7 @@ downvoteItem = function (collection, item, user) {
|
||||||
item = downvoteMethodCallbacks.reduce(function(result, currentFunction) {
|
item = downvoteMethodCallbacks.reduce(function(result, currentFunction) {
|
||||||
return currentFunction(collection, result, user);
|
return currentFunction(collection, result, user);
|
||||||
}, item);
|
}, item);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
votePower = getVotePower(user);
|
votePower = getVotePower(user);
|
||||||
|
@ -239,7 +239,7 @@ cancelDownvote = function (collection, item, user) {
|
||||||
item = cancelDownvoteMethodCallbacks.reduce(function(result, currentFunction) {
|
item = cancelDownvoteMethodCallbacks.reduce(function(result, currentFunction) {
|
||||||
return currentFunction(collection, result, user);
|
return currentFunction(collection, result, user);
|
||||||
}, item);
|
}, item);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
votePower = getVotePower(user);
|
votePower = getVotePower(user);
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
// array containing properties to be added to the post/settings/comments schema on startup.
|
// array containing properties to be added to the post/settings/comments schema on startup.
|
||||||
addToPostSchema = [];
|
addToPostSchema = [];
|
||||||
addToCommentsSchema = [];
|
addToCommentsSchema = [];
|
||||||
addToSettingsSchema = [];
|
|
||||||
addToUserSchema = [];
|
addToUserSchema = [];
|
||||||
|
|
||||||
SimpleSchema.extendOptions({
|
SimpleSchema.extendOptions({
|
||||||
|
@ -25,7 +24,7 @@ postStatuses = [
|
||||||
value: 3,
|
value: 3,
|
||||||
label: 'Rejected'
|
label: 'Rejected'
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
STATUS_PENDING=1;
|
STATUS_PENDING=1;
|
||||||
STATUS_APPROVED=2;
|
STATUS_APPROVED=2;
|
||||||
|
@ -96,7 +95,7 @@ viewsMenu = [
|
||||||
label: 'scheduled',
|
label: 'scheduled',
|
||||||
description: 'future_scheduled_posts',
|
description: 'future_scheduled_posts',
|
||||||
adminOnly: true
|
adminOnly: true
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
// array containing items in the admin menu
|
// array containing items in the admin menu
|
||||||
|
@ -139,7 +138,7 @@ userMenu = [
|
||||||
label: 'sign_out',
|
label: 'sign_out',
|
||||||
description: 'sign_out'
|
description: 'sign_out'
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
// ------------------------------------- Views -------------------------------- //
|
// ------------------------------------- Views -------------------------------- //
|
||||||
|
|
||||||
|
|
||||||
|
@ -160,19 +159,19 @@ viewParameters.top = function (terms) {
|
||||||
return {
|
return {
|
||||||
options: {sort: {sticky: -1, score: -1}}
|
options: {sort: {sticky: -1, score: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.new = function (terms) {
|
viewParameters.new = function (terms) {
|
||||||
return {
|
return {
|
||||||
options: {sort: {sticky: -1, postedAt: -1}}
|
options: {sort: {sticky: -1, postedAt: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.best = function (terms) {
|
viewParameters.best = function (terms) {
|
||||||
return {
|
return {
|
||||||
options: {sort: {sticky: -1, baseScore: -1}}
|
options: {sort: {sticky: -1, baseScore: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.pending = function (terms) {
|
viewParameters.pending = function (terms) {
|
||||||
return {
|
return {
|
||||||
|
@ -182,21 +181,21 @@ viewParameters.pending = function (terms) {
|
||||||
options: {sort: {createdAt: -1}},
|
options: {sort: {createdAt: -1}},
|
||||||
showFuture: true
|
showFuture: true
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.scheduled = function (terms) {
|
viewParameters.scheduled = function (terms) {
|
||||||
return {
|
return {
|
||||||
find: {postedAt: {$gte: new Date()}},
|
find: {postedAt: {$gte: new Date()}},
|
||||||
options: {sort: {postedAt: -1}}
|
options: {sort: {postedAt: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.userPosts = function (terms) {
|
viewParameters.userPosts = function (terms) {
|
||||||
return {
|
return {
|
||||||
find: {userId: terms.userId},
|
find: {userId: terms.userId},
|
||||||
options: {limit: 5, sort: {postedAt: -1}}
|
options: {limit: 5, sort: {postedAt: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.userUpvotedPosts = function (terms) {
|
viewParameters.userUpvotedPosts = function (terms) {
|
||||||
var user = Meteor.users.findOne(terms.userId);
|
var user = Meteor.users.findOne(terms.userId);
|
||||||
|
@ -205,7 +204,7 @@ viewParameters.userUpvotedPosts = function (terms) {
|
||||||
find: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
|
find: {_id: {$in: postsIds}, userId: {$ne: terms.userId}}, // exclude own posts
|
||||||
options: {limit: 5, sort: {postedAt: -1}}
|
options: {limit: 5, sort: {postedAt: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
viewParameters.userDownvotedPosts = function (terms) {
|
viewParameters.userDownvotedPosts = function (terms) {
|
||||||
var user = Meteor.users.findOne(terms.userId);
|
var user = Meteor.users.findOne(terms.userId);
|
||||||
|
@ -215,7 +214,7 @@ viewParameters.userDownvotedPosts = function (terms) {
|
||||||
find: {_id: {$in: postsIds}},
|
find: {_id: {$in: postsIds}},
|
||||||
options: {limit: 5, sort: {postedAt: -1}}
|
options: {limit: 5, sort: {postedAt: -1}}
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
heroModules = [];
|
heroModules = [];
|
||||||
|
|
||||||
|
@ -287,7 +286,7 @@ postMeta = [
|
||||||
template: 'postAdmin',
|
template: 'postAdmin',
|
||||||
order: 50
|
order: 50
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
// ------------------------------ Callbacks ------------------------------ //
|
// ------------------------------ Callbacks ------------------------------ //
|
||||||
|
|
||||||
postClassCallbacks = [];
|
postClassCallbacks = [];
|
||||||
|
@ -358,7 +357,7 @@ userProfileEdit = [
|
||||||
template: 'userAccount',
|
template: 'userAccount',
|
||||||
order: 1
|
order: 1
|
||||||
}
|
}
|
||||||
]
|
];
|
||||||
|
|
||||||
userProfileCompleteChecks.push(
|
userProfileCompleteChecks.push(
|
||||||
function(user) {
|
function(user) {
|
||||||
|
@ -373,7 +372,7 @@ templates = {}
|
||||||
getTemplate = function (name) {
|
getTemplate = function (name) {
|
||||||
// if template has been overwritten, return this; else return template name
|
// if template has been overwritten, return this; else return template name
|
||||||
return !!templates[name] ? templates[name] : name;
|
return !!templates[name] ? templates[name] : name;
|
||||||
}
|
};
|
||||||
|
|
||||||
// ------------------------------ Theme Settings ------------------------------ //
|
// ------------------------------ Theme Settings ------------------------------ //
|
||||||
|
|
||||||
|
|
|
@ -14,17 +14,16 @@ Package.onUse(function (api) {
|
||||||
'STATUS_PENDING',
|
'STATUS_PENDING',
|
||||||
'STATUS_APPROVED',
|
'STATUS_APPROVED',
|
||||||
'STATUS_REJECTED',
|
'STATUS_REJECTED',
|
||||||
|
|
||||||
'adminMenu',
|
'adminMenu',
|
||||||
'viewsMenu',
|
'viewsMenu',
|
||||||
'userMenu',
|
'userMenu',
|
||||||
'addToPostSchema',
|
'addToPostSchema',
|
||||||
'addToCommentsSchema',
|
'addToCommentsSchema',
|
||||||
'addToSettingsSchema',
|
|
||||||
'addToUserSchema',
|
'addToUserSchema',
|
||||||
'preloadSubscriptions',
|
'preloadSubscriptions',
|
||||||
'primaryNav',
|
'primaryNav',
|
||||||
'secondaryNav',
|
'secondaryNav',
|
||||||
'mobileNav',
|
'mobileNav',
|
||||||
'viewParameters',
|
'viewParameters',
|
||||||
|
|
||||||
|
@ -45,7 +44,7 @@ Package.onUse(function (api) {
|
||||||
'postAfterSubmitMethodCallbacks',
|
'postAfterSubmitMethodCallbacks',
|
||||||
|
|
||||||
'postApproveCallbacks',
|
'postApproveCallbacks',
|
||||||
|
|
||||||
'postEditRenderedCallbacks',
|
'postEditRenderedCallbacks',
|
||||||
'postEditClientCallbacks',
|
'postEditClientCallbacks',
|
||||||
'postEditMethodCallbacks',
|
'postEditMethodCallbacks',
|
||||||
|
@ -71,14 +70,14 @@ Package.onUse(function (api) {
|
||||||
'downvoteMethodCallbacks',
|
'downvoteMethodCallbacks',
|
||||||
'cancelUpvoteMethodCallbacks',
|
'cancelUpvoteMethodCallbacks',
|
||||||
'cancelDownvoteMethodCallbacks',
|
'cancelDownvoteMethodCallbacks',
|
||||||
|
|
||||||
'userEditRenderedCallbacks',
|
'userEditRenderedCallbacks',
|
||||||
'userEditClientCallbacks',
|
'userEditClientCallbacks',
|
||||||
'userProfileCompleteChecks',
|
'userProfileCompleteChecks',
|
||||||
'userProfileDisplay',
|
'userProfileDisplay',
|
||||||
'userProfileEdit',
|
'userProfileEdit',
|
||||||
'userCreatedCallbacks',
|
'userCreatedCallbacks',
|
||||||
|
|
||||||
'getTemplate',
|
'getTemplate',
|
||||||
'templates',
|
'templates',
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,4 @@ var customSetting = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(customSetting);
|
Settings.addToSchema(customSetting);
|
||||||
|
|
|
@ -19,6 +19,7 @@ Package.onUse(function (api) {
|
||||||
'iron:router', // routing package
|
'iron:router', // routing package
|
||||||
'telescope-base', // basic Telescope hooks and objects
|
'telescope-base', // basic Telescope hooks and objects
|
||||||
'telescope-lib', // useful functions
|
'telescope-lib', // useful functions
|
||||||
|
'telescope-settings',
|
||||||
'telescope-i18n', // internationalization wrapper
|
'telescope-i18n', // internationalization wrapper
|
||||||
'fourseven:scss' // SCSS compilation package
|
'fourseven:scss' // SCSS compilation package
|
||||||
]);
|
]);
|
||||||
|
@ -69,7 +70,7 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
'lib/server/publications.js'
|
'lib/server/publications.js'
|
||||||
], ['server']);
|
], ['server']);
|
||||||
|
|
||||||
// i18n languages (must come last)
|
// i18n languages (must come last)
|
||||||
|
|
||||||
|
@ -83,4 +84,4 @@ Package.onUse(function (api) {
|
||||||
'myFunction'
|
'myFunction'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,7 +6,7 @@ var coreSubscriptions = new SubsManager({
|
||||||
});
|
});
|
||||||
|
|
||||||
PostsDailyController = RouteController.extend({
|
PostsDailyController = RouteController.extend({
|
||||||
|
|
||||||
onBeforeAction: function () {
|
onBeforeAction: function () {
|
||||||
this.render(getTemplate('postListTop'), {to: 'postListTop'});
|
this.render(getTemplate('postListTop'), {to: 'postListTop'});
|
||||||
this.next();
|
this.next();
|
||||||
|
@ -31,7 +31,7 @@ PostsDailyController = RouteController.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
return i18n.t('daily') + ' - ' + getSetting('title', "Telescope");
|
return i18n.t('daily') + ' - ' + Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
|
|
||||||
getDescription: function () {
|
getDescription: function () {
|
||||||
|
@ -42,10 +42,10 @@ PostsDailyController = RouteController.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
|
|
||||||
Router.route('/daily/:days?', {
|
Router.route('/daily/:days?', {
|
||||||
name: 'postsDaily',
|
name: 'postsDaily',
|
||||||
controller: PostsDailyController
|
controller: PostsDailyController
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,10 +3,11 @@ Package.describe({summary: "Telescope daily view"});
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function (api) {
|
||||||
|
|
||||||
api.use([
|
api.use([
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'iron:router',
|
'iron:router',
|
||||||
'meteorhacks:fast-render',
|
'meteorhacks:fast-render',
|
||||||
'meteorhacks:subs-manager',
|
'meteorhacks:subs-manager',
|
||||||
'tap:i18n',
|
'tap:i18n',
|
||||||
'telescope-singleday',
|
'telescope-singleday',
|
||||||
|
@ -43,4 +44,4 @@ Package.onUse(function (api) {
|
||||||
], ["client", "server"]);
|
], ["client", "server"]);
|
||||||
|
|
||||||
api.export(['PostsDailyController']);
|
api.export(['PostsDailyController']);
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,26 +15,26 @@ getEmailTemplate = function (template) {
|
||||||
buildEmailTemplate = function (htmlContent) {
|
buildEmailTemplate = function (htmlContent) {
|
||||||
|
|
||||||
var emailProperties = {
|
var emailProperties = {
|
||||||
headerColor: getSetting('headerColor', '#444444'),
|
headerColor: Settings.get('headerColor', '#444444'),
|
||||||
buttonColor: getSetting('buttonColor', '#DD3416'),
|
buttonColor: Settings.get('buttonColor', '#DD3416'),
|
||||||
siteName: getSetting('title'),
|
siteName: Settings.get('title'),
|
||||||
tagline: getSetting('tagline'),
|
tagline: Settings.get('tagline'),
|
||||||
siteUrl: getSiteUrl(),
|
siteUrl: getSiteUrl(),
|
||||||
body: htmlContent,
|
body: htmlContent,
|
||||||
unsubscribe: '',
|
unsubscribe: '',
|
||||||
accountLink: getSiteUrl()+'account',
|
accountLink: getSiteUrl()+'account',
|
||||||
footer: getSetting('emailFooter'),
|
footer: Settings.get('emailFooter'),
|
||||||
logoUrl: getSetting('logoUrl'),
|
logoUrl: Settings.get('logoUrl'),
|
||||||
logoHeight: getSetting('logoHeight'),
|
logoHeight: Settings.get('logoHeight'),
|
||||||
logoWidth: getSetting('logoWidth')
|
logoWidth: Settings.get('logoWidth')
|
||||||
}
|
}
|
||||||
|
|
||||||
var emailHTML = Handlebars.templates[getTemplate('emailWrapper')](emailProperties);
|
var emailHTML = Handlebars.templates[getTemplate('emailWrapper')](emailProperties);
|
||||||
|
|
||||||
var inlinedHTML = juice(emailHTML);
|
var inlinedHTML = juice(emailHTML);
|
||||||
|
|
||||||
var doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
var doctype = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
|
||||||
|
|
||||||
return doctype+inlinedHTML;
|
return doctype+inlinedHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,13 +42,13 @@ sendEmail = function(to, subject, html, text){
|
||||||
|
|
||||||
// TODO: limit who can send emails
|
// TODO: limit who can send emails
|
||||||
// TODO: fix this error: Error: getaddrinfo ENOTFOUND
|
// TODO: fix this error: Error: getaddrinfo ENOTFOUND
|
||||||
|
|
||||||
var from = getSetting('defaultEmail', 'noreply@example.com');
|
var from = Settings.get('defaultEmail', 'noreply@example.com');
|
||||||
var siteName = getSetting('title', 'Telescope');
|
var siteName = Settings.get('title', 'Telescope');
|
||||||
var subject = '['+siteName+'] '+subject;
|
var subject = '['+siteName+'] '+subject;
|
||||||
|
|
||||||
if (typeof text == 'undefined'){
|
if (typeof text == 'undefined'){
|
||||||
// Auto-generate text version if it doesn't exist. Has bugs, but should be good enough.
|
// Auto-generate text version if it doesn't exist. Has bugs, but should be good enough.
|
||||||
var text = htmlToText.fromString(html, {
|
var text = htmlToText.fromString(html, {
|
||||||
wordwrap: 130
|
wordwrap: 130
|
||||||
});
|
});
|
||||||
|
@ -62,9 +62,9 @@ sendEmail = function(to, subject, html, text){
|
||||||
// console.log('text: '+text);
|
// console.log('text: '+text);
|
||||||
|
|
||||||
var email = {
|
var email = {
|
||||||
from: from,
|
from: from,
|
||||||
to: to,
|
to: to,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
text: text,
|
text: text,
|
||||||
html: html
|
html: html
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ buildAndSendEmail = function (to, subject, template, properties) {
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
testEmail: function () {
|
testEmail: function () {
|
||||||
if(isAdminById(this.userId)){
|
if(isAdminById(this.userId)){
|
||||||
var email = buildAndSendEmail (getSetting('defaultEmail'), 'Telescope email test', 'emailTest', {date: new Date()});
|
var email = buildAndSendEmail (Settings.get('defaultEmail'), 'Telescope email test', 'emailTest', {date: new Date()});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -102,4 +102,4 @@ function adminUserCreationNotification (user) {
|
||||||
});
|
});
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
userCreatedCallbacks.push(adminUserCreationNotification);
|
userCreatedCallbacks.push(adminUserCreationNotification);
|
||||||
|
|
|
@ -13,6 +13,7 @@ Package.onUse(function (api) {
|
||||||
api.use([
|
api.use([
|
||||||
'iron:router',
|
'iron:router',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-i18n',
|
'telescope-i18n',
|
||||||
'tap:i18n'
|
'tap:i18n'
|
||||||
|
@ -41,7 +42,7 @@ Package.onUse(function (api) {
|
||||||
'lib/server/templates/emailTest.handlebars',
|
'lib/server/templates/emailTest.handlebars',
|
||||||
'lib/server/templates/emailWrapper.handlebars',
|
'lib/server/templates/emailWrapper.handlebars',
|
||||||
], ['server']);
|
], ['server']);
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
"i18n/de.i18n.json",
|
"i18n/de.i18n.json",
|
||||||
"i18n/en.i18n.json",
|
"i18n/en.i18n.json",
|
||||||
|
@ -52,9 +53,9 @@ Package.onUse(function (api) {
|
||||||
], ["client", "server"]);
|
], ["client", "server"]);
|
||||||
|
|
||||||
api.export([
|
api.export([
|
||||||
'buildEmailTemplate',
|
'buildEmailTemplate',
|
||||||
'sendEmail',
|
'sendEmail',
|
||||||
'buildAndSendEmail',
|
'buildAndSendEmail',
|
||||||
'getEmailTemplate'
|
'getEmailTemplate'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,8 +61,8 @@ Template.afPostThumbnail.helpers({
|
||||||
return atts;
|
return atts;
|
||||||
},
|
},
|
||||||
style: function () {
|
style: function () {
|
||||||
var thumbnailWidth = getSetting('thumbnailWidth', 200);
|
var thumbnailWidth = Settings.get('thumbnailWidth', 200);
|
||||||
var thumbnailHeight = getSetting('thumbnailHeight', 125);
|
var thumbnailHeight = Settings.get('thumbnailHeight', 125);
|
||||||
return "width: "+thumbnailWidth+"px; height: "+thumbnailHeight+"px;"
|
return "width: "+thumbnailWidth+"px; height: "+thumbnailHeight+"px;"
|
||||||
},
|
},
|
||||||
embedlyKeyExists: function () {
|
embedlyKeyExists: function () {
|
||||||
|
|
|
@ -26,7 +26,7 @@ var mediaProperty = {
|
||||||
addToPostSchema.push(mediaProperty);
|
addToPostSchema.push(mediaProperty);
|
||||||
|
|
||||||
postThumbnail.push({
|
postThumbnail.push({
|
||||||
template: 'postThumbnail',
|
template: 'postThumbnail',
|
||||||
order: 15
|
order: 15
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ var embedlyKeyProperty = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(embedlyKeyProperty);
|
Settings.addToSchema(embedlyKeyProperty);
|
||||||
|
|
||||||
var thumbnailWidthProperty = {
|
var thumbnailWidthProperty = {
|
||||||
propertyName: 'thumbnailWidth',
|
propertyName: 'thumbnailWidth',
|
||||||
|
@ -53,7 +53,7 @@ var thumbnailWidthProperty = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(thumbnailWidthProperty);
|
Settings.addToSchema(thumbnailWidthProperty);
|
||||||
|
|
||||||
var thumbnailHeightProperty = {
|
var thumbnailHeightProperty = {
|
||||||
propertyName: 'thumbnailHeight',
|
propertyName: 'thumbnailHeight',
|
||||||
|
@ -65,10 +65,10 @@ var thumbnailHeightProperty = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(thumbnailHeightProperty);
|
Settings.addToSchema(thumbnailHeightProperty);
|
||||||
|
|
||||||
// add callback that adds "has-thumbnail" or "no-thumbnail" CSS classes
|
// add callback that adds "has-thumbnail" or "no-thumbnail" CSS classes
|
||||||
postClassCallbacks.push(function (post, postClass){
|
postClassCallbacks.push(function (post, postClass){
|
||||||
var thumbnailClass = !!post.thumbnailUrl ? "has-thumbnail" : "no-thumbnail";
|
var thumbnailClass = !!post.thumbnailUrl ? "has-thumbnail" : "no-thumbnail";
|
||||||
return postClass + " " + thumbnailClass;
|
return postClass + " " + thumbnailClass;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
getEmbedlyData = function (url) {
|
getEmbedlyData = function (url) {
|
||||||
var data = {}
|
var data = {}
|
||||||
var extractBase = 'http://api.embed.ly/1/extract';
|
var extractBase = 'http://api.embed.ly/1/extract';
|
||||||
var embedlyKey = getSetting('embedlyKey');
|
var embedlyKey = Settings.get('embedlyKey');
|
||||||
var thumbnailWidth = getSetting('thumbnailWidth', 200);
|
var thumbnailWidth = Settings.get('thumbnailWidth', 200);
|
||||||
var thumbnailHeight = getSetting('thumbnailHeight', 125);
|
var thumbnailHeight = Settings.get('thumbnailHeight', 125);
|
||||||
|
|
||||||
if(!embedlyKey) {
|
if(!embedlyKey) {
|
||||||
// fail silently to still let the post be submitted as usual
|
// fail silently to still let the post be submitted as usual
|
||||||
|
@ -12,7 +12,7 @@ getEmbedlyData = function (url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var result = Meteor.http.get(extractBase, {
|
var result = Meteor.http.get(extractBase, {
|
||||||
params: {
|
params: {
|
||||||
key: embedlyKey,
|
key: embedlyKey,
|
||||||
|
@ -106,11 +106,11 @@ Meteor.methods({
|
||||||
return getEmbedlyData(url);
|
return getEmbedlyData(url);
|
||||||
},
|
},
|
||||||
embedlyKeyExists: function () {
|
embedlyKeyExists: function () {
|
||||||
return !!getSetting('embedlyKey');
|
return !!Settings.get('embedlyKey');
|
||||||
},
|
},
|
||||||
regenerateEmbedlyData: function (post) {
|
regenerateEmbedlyData: function (post) {
|
||||||
if (can.edit(Meteor.user(), post)) {
|
if (can.edit(Meteor.user(), post)) {
|
||||||
addMediaAfterSubmit(post);
|
addMediaAfterSubmit(post);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -12,6 +12,7 @@ Package.onUse( function(api) {
|
||||||
api.use([
|
api.use([
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'aldeed:autoform',
|
'aldeed:autoform',
|
||||||
'tap:i18n',
|
'tap:i18n',
|
||||||
'fourseven:scss',
|
'fourseven:scss',
|
||||||
|
|
|
@ -33,15 +33,15 @@ setLanguage = function (language) {
|
||||||
i18n = {
|
i18n = {
|
||||||
t: function (str, options) {
|
t: function (str, options) {
|
||||||
if (Meteor.isServer) {
|
if (Meteor.isServer) {
|
||||||
return TAPi18n.__(str, options, getSetting('language', 'en'));
|
return TAPi18n.__(str, options, Settings.get('language', 'en'));
|
||||||
} else {
|
} else {
|
||||||
return TAPi18n.__(str, options);
|
return TAPi18n.__(str, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
|
|
||||||
if (Meteor.isClient) {
|
if (Meteor.isClient) {
|
||||||
|
|
||||||
// doesn't quite work yet
|
// doesn't quite work yet
|
||||||
|
@ -56,7 +56,7 @@ Meteor.startup(function () {
|
||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
|
|
||||||
setLanguage(getSetting('language', 'en'));
|
setLanguage(Settings.get('language', 'en'));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,19 +35,19 @@ userProfileEdit.push({
|
||||||
|
|
||||||
function setStartingInvites (user) {
|
function setStartingInvites (user) {
|
||||||
// give new users a few invites (default to 3)
|
// give new users a few invites (default to 3)
|
||||||
user.inviteCount = getSetting('startInvitesCount', 3);
|
user.inviteCount = Settings.get('startInvitesCount', 3);
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
userCreatedCallbacks.push(setStartingInvites);
|
userCreatedCallbacks.push(setStartingInvites);
|
||||||
|
|
||||||
function checkIfInvited (user) {
|
function checkIfInvited (user) {
|
||||||
// if the new user has been invited
|
// if the new user has been invited
|
||||||
// set her status accordingly and update invitation info
|
// set her status accordingly and update invitation info
|
||||||
if(invitesEnabled() && getEmail(user)){
|
if(invitesEnabled() && getEmail(user)){
|
||||||
var invite = Invites.findOne({ invitedUserEmail : getEmail(user) });
|
var invite = Invites.findOne({ invitedUserEmail : getEmail(user) });
|
||||||
if(invite){
|
if(invite){
|
||||||
var invitedBy = Meteor.users.findOne({ _id : invite.invitingUserId });
|
var invitedBy = Meteor.users.findOne({ _id : invite.invitingUserId });
|
||||||
|
|
||||||
user = _.extend(user, {
|
user = _.extend(user, {
|
||||||
isInvited: true,
|
isInvited: true,
|
||||||
invitedBy: invitedBy._id,
|
invitedBy: invitedBy._id,
|
||||||
|
|
|
@ -59,7 +59,7 @@ Meteor.methods({
|
||||||
}});
|
}});
|
||||||
}
|
}
|
||||||
|
|
||||||
var communityName = getSetting('title','Telescope'),
|
var communityName = Settings.get('title','Telescope'),
|
||||||
emailSubject = 'You are invited to try '+communityName,
|
emailSubject = 'You are invited to try '+communityName,
|
||||||
emailProperties = {
|
emailProperties = {
|
||||||
newUser : typeof user === 'undefined',
|
newUser : typeof user === 'undefined',
|
||||||
|
@ -79,4 +79,4 @@ Meteor.methods({
|
||||||
newUser : typeof user === 'undefined'
|
newUser : typeof user === 'undefined'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -18,6 +18,7 @@ Package.onUse(function (api) {
|
||||||
'tap:i18n',
|
'tap:i18n',
|
||||||
'iron:router',
|
'iron:router',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-i18n',
|
'telescope-i18n',
|
||||||
'aldeed:simple-schema',
|
'aldeed:simple-schema',
|
||||||
|
|
|
@ -8,8 +8,8 @@ var kadiraAppIdProperty = {
|
||||||
group: 'kadira'
|
group: 'kadira'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
addToSettingsSchema.push(kadiraAppIdProperty);
|
Settings.addToSchema(kadiraAppIdProperty);
|
||||||
|
|
||||||
var kadiraAppSecretProperty = {
|
var kadiraAppSecretProperty = {
|
||||||
propertyName: 'kadiraAppSecret',
|
propertyName: 'kadiraAppSecret',
|
||||||
|
@ -22,5 +22,5 @@ var kadiraAppSecretProperty = {
|
||||||
private: true
|
private: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
addToSettingsSchema.push(kadiraAppSecretProperty);
|
Settings.addToSchema(kadiraAppSecretProperty);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Meteor.startup(function() {
|
Meteor.startup(function() {
|
||||||
if(!!getSetting('kadiraAppId') && !!getSetting('kadiraAppSecret')){
|
if(!!Settings.get('kadiraAppId') && !!Settings.get('kadiraAppSecret')){
|
||||||
Kadira.connect(getSetting('kadiraAppId'), getSetting('kadiraAppSecret'));
|
Kadira.connect(Settings.get('kadiraAppId'), Settings.get('kadiraAppSecret'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,8 +8,9 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
api.use([
|
api.use([
|
||||||
'templating',
|
'templating',
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'tap:i18n',
|
'tap:i18n',
|
||||||
'meteorhacks:kadira@2.20.1'
|
'meteorhacks:kadira@2.20.1'
|
||||||
], ['client', 'server']);
|
], ['client', 'server']);
|
||||||
|
@ -27,4 +28,4 @@ Package.onUse(function (api) {
|
||||||
"i18n/en.i18n.json"
|
"i18n/en.i18n.json"
|
||||||
], ["client", "server"]);
|
], ["client", "server"]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,29 +1,7 @@
|
||||||
getSiteUrl = function () {
|
getSiteUrl = function () {
|
||||||
return getSetting('siteUrl', Meteor.absoluteUrl());
|
return Settings.get('siteUrl', Meteor.absoluteUrl());
|
||||||
}
|
|
||||||
|
|
||||||
getSetting = function(setting, defaultValue){
|
|
||||||
var settings = Settings.find().fetch()[0];
|
|
||||||
|
|
||||||
if (Meteor.isServer && Meteor.settings && !!Meteor.settings[setting]) { // if on the server, look in Meteor.settings
|
|
||||||
return Meteor.settings[setting];
|
|
||||||
|
|
||||||
} else if (Meteor.settings && Meteor.settings.public && !!Meteor.settings.public[setting]) { // look in Meteor.settings.public
|
|
||||||
return Meteor.settings.public[setting];
|
|
||||||
|
|
||||||
} else if(settings && (typeof settings[setting] !== 'undefined')) { // look in Settings collection
|
|
||||||
return settings[setting];
|
|
||||||
|
|
||||||
} else if (typeof defaultValue !== 'undefined') { // fallback to default
|
|
||||||
return defaultValue;
|
|
||||||
|
|
||||||
} else { // or return undefined
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
removeSetting = function (setting) {
|
removeSetting = function (setting) {
|
||||||
var settings = Settings.find().fetch()[0];
|
var settings = Settings.find().fetch()[0];
|
||||||
console.log(settings._id)
|
console.log(settings._id)
|
||||||
|
@ -45,15 +23,15 @@ getThemeSetting = function(setting, defaultValue){
|
||||||
|
|
||||||
camelToDash = function (str) {
|
camelToDash = function (str) {
|
||||||
return str.replace(/\W+/g, '-').replace(/([a-z\d])([A-Z])/g, '$1-$2').toLowerCase();
|
return str.replace(/\W+/g, '-').replace(/([a-z\d])([A-Z])/g, '$1-$2').toLowerCase();
|
||||||
}
|
};
|
||||||
|
|
||||||
camelCaseify = function(str) {
|
camelCaseify = function(str) {
|
||||||
return dashToCamel(str.replace(' ', '-'));
|
return dashToCamel(str.replace(' ', '-'));
|
||||||
}
|
};
|
||||||
|
|
||||||
dashToCamel = function (str) {
|
dashToCamel = function (str) {
|
||||||
return str.replace(/(\-[a-z])/g, function($1){return $1.toUpperCase().replace('-','');});
|
return str.replace(/(\-[a-z])/g, function($1){return $1.toUpperCase().replace('-','');});
|
||||||
}
|
};
|
||||||
|
|
||||||
trimWords = function(s, numWords) {
|
trimWords = function(s, numWords) {
|
||||||
expString = s.split(/\s+/,numWords);
|
expString = s.split(/\s+/,numWords);
|
||||||
|
@ -64,4 +42,4 @@ trimWords = function(s, numWords) {
|
||||||
|
|
||||||
capitalise = function (string) {
|
capitalise = function (string) {
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
}
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@ can = {};
|
||||||
//
|
//
|
||||||
// return true if all is well, false
|
// return true if all is well, false
|
||||||
can.view = function (user) {
|
can.view = function (user) {
|
||||||
if (getSetting('requireViewInvite', false)) {
|
if (Settings.get('requireViewInvite', false)) {
|
||||||
|
|
||||||
if (Meteor.isClient) {
|
if (Meteor.isClient) {
|
||||||
// on client only, default to the current user
|
// on client only, default to the current user
|
||||||
|
@ -32,7 +32,7 @@ can.viewRejectedPosts = function (user) {
|
||||||
|
|
||||||
can.viewById = function (userId) {
|
can.viewById = function (userId) {
|
||||||
// if an invite is required to view, run permission check, else return true
|
// if an invite is required to view, run permission check, else return true
|
||||||
if (getSetting('requireViewInvite', false)) {
|
if (Settings.get('requireViewInvite', false)) {
|
||||||
return !!userId ? can.view(Meteor.users.findOne(userId)) : false;
|
return !!userId ? can.view(Meteor.users.findOne(userId)) : false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -44,7 +44,7 @@ can.post = function (user, returnError) {
|
||||||
return returnError ? "no_account" : false;
|
return returnError ? "no_account" : false;
|
||||||
} else if (isAdmin(user)) {
|
} else if (isAdmin(user)) {
|
||||||
return true;
|
return true;
|
||||||
} else if (getSetting('requirePostInvite')) {
|
} else if (Settings.get('requirePostInvite')) {
|
||||||
if (user.isInvited) {
|
if (user.isInvited) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -16,20 +16,19 @@ Package.onUse(function (api) {
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
'lib/lib.js',
|
'lib/lib.js',
|
||||||
'lib/deep.js',
|
'lib/deep.js',
|
||||||
'lib/deep_extend.js',
|
'lib/deep_extend.js',
|
||||||
'lib/autolink.js',
|
'lib/autolink.js',
|
||||||
'lib/permissions.js'
|
'lib/permissions.js'
|
||||||
], ['client', 'server']);
|
], ['client', 'server']);
|
||||||
|
|
||||||
api.add_files(['lib/client/jquery.exists.js'], ['client']);
|
api.add_files(['lib/client/jquery.exists.js'], ['client']);
|
||||||
|
|
||||||
api.export([
|
api.export([
|
||||||
'deepExtend',
|
'deepExtend',
|
||||||
'camelToDash',
|
'camelToDash',
|
||||||
'dashToCamel',
|
'dashToCamel',
|
||||||
'camelCaseify',
|
'camelCaseify',
|
||||||
'getSetting',
|
|
||||||
'removeSetting',
|
'removeSetting',
|
||||||
'getThemeSetting',
|
'getThemeSetting',
|
||||||
'getSiteUrl',
|
'getSiteUrl',
|
||||||
|
@ -38,4 +37,4 @@ Package.onUse(function (api) {
|
||||||
'_',
|
'_',
|
||||||
'capitalise'
|
'capitalise'
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ Meteor.startup(function () {
|
||||||
return !!this.url ? this.url : getSiteUrl() + "posts/"+this._id;
|
return !!this.url ? this.url : getSiteUrl() + "posts/"+this._id;
|
||||||
},
|
},
|
||||||
viaTwitter: function () {
|
viaTwitter: function () {
|
||||||
return !!getSetting('twitterAccount') ? 'via='+getSetting('twitterAccount') : '';
|
return !!Settings.get('twitterAccount') ? 'via='+Settings.get('twitterAccount') : '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -19,4 +19,4 @@ Meteor.startup(function () {
|
||||||
$share.toggleClass("hidden");
|
$share.toggleClass("hidden");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,12 @@ Package.describe({summary: "Telescope share module package"});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function (api) {
|
||||||
|
|
||||||
api.use(['telescope-lib', 'telescope-base', 'fourseven:scss'], ['client', 'server']);
|
api.use([
|
||||||
|
'telescope-lib',
|
||||||
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
|
'fourseven:scss'
|
||||||
|
], ['client', 'server']);
|
||||||
|
|
||||||
api.use([
|
api.use([
|
||||||
'jquery',
|
'jquery',
|
||||||
|
@ -13,6 +18,6 @@ Package.onUse(function (api) {
|
||||||
api.add_files(['lib/share.js'], ['client', 'server']);
|
api.add_files(['lib/share.js'], ['client', 'server']);
|
||||||
|
|
||||||
api.add_files(['lib/client/post_share.html', 'lib/client/post_share.js', 'lib/client/post_share.scss'], ['client']);
|
api.add_files(['lib/client/post_share.html', 'lib/client/post_share.js', 'lib/client/post_share.scss'], ['client']);
|
||||||
|
|
||||||
// api.export();
|
// api.export();
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,7 @@ var dismissBanner = function () {
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
Template[getTemplate('newsletterBanner')].helpers({
|
Template[getTemplate('newsletterBanner')].helpers({
|
||||||
siteName: function () {
|
siteName: function () {
|
||||||
return getSetting('title');
|
return Settings.get('title');
|
||||||
},
|
},
|
||||||
isNotConnected: function () {
|
isNotConnected: function () {
|
||||||
return !Meteor.user()
|
return !Meteor.user()
|
||||||
|
@ -30,7 +30,7 @@ Meteor.startup(function () {
|
||||||
showBanner: function () {
|
showBanner: function () {
|
||||||
// note: should not be reactive
|
// note: should not be reactive
|
||||||
if(
|
if(
|
||||||
getSetting('showBanner', false) == false
|
Settings.get('showBanner', false) == false
|
||||||
|| !can.view(Meteor.user())
|
|| !can.view(Meteor.user())
|
||||||
|| Router.current().location.get().path != '/'
|
|| Router.current().location.get().path != '/'
|
||||||
|| Cookie.get('showBanner') == "no"
|
|| Cookie.get('showBanner') == "no"
|
||||||
|
|
|
@ -55,7 +55,7 @@ var enableNewsletter = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(enableNewsletter);
|
Settings.addToSchema(enableNewsletter);
|
||||||
|
|
||||||
var showBanner = {
|
var showBanner = {
|
||||||
propertyName: 'showBanner',
|
propertyName: 'showBanner',
|
||||||
|
@ -69,7 +69,7 @@ var showBanner = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(showBanner);
|
Settings.addToSchema(showBanner);
|
||||||
|
|
||||||
var mailChimpAPIKey = {
|
var mailChimpAPIKey = {
|
||||||
propertyName: 'mailChimpAPIKey',
|
propertyName: 'mailChimpAPIKey',
|
||||||
|
@ -82,7 +82,7 @@ var mailChimpAPIKey = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(mailChimpAPIKey);
|
Settings.addToSchema(mailChimpAPIKey);
|
||||||
|
|
||||||
var mailChimpListId = {
|
var mailChimpListId = {
|
||||||
propertyName: 'mailChimpListId',
|
propertyName: 'mailChimpListId',
|
||||||
|
@ -96,7 +96,7 @@ var mailChimpListId = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(mailChimpListId);
|
Settings.addToSchema(mailChimpListId);
|
||||||
|
|
||||||
var postsPerNewsletter = {
|
var postsPerNewsletter = {
|
||||||
propertyName: 'postsPerNewsletter',
|
propertyName: 'postsPerNewsletter',
|
||||||
|
@ -108,7 +108,7 @@ var postsPerNewsletter = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(postsPerNewsletter);
|
Settings.addToSchema(postsPerNewsletter);
|
||||||
|
|
||||||
var newsletterFrequency = {
|
var newsletterFrequency = {
|
||||||
propertyName: 'newsletterFrequency',
|
propertyName: 'newsletterFrequency',
|
||||||
|
@ -139,7 +139,7 @@ var newsletterFrequency = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(newsletterFrequency);
|
Settings.addToSchema(newsletterFrequency);
|
||||||
|
|
||||||
var newsletterTime = {
|
var newsletterTime = {
|
||||||
propertyName: 'newsletterTime',
|
propertyName: 'newsletterTime',
|
||||||
|
@ -154,7 +154,7 @@ var newsletterTime = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(newsletterTime);
|
Settings.addToSchema(newsletterTime);
|
||||||
|
|
||||||
var autoSubscribe = {
|
var autoSubscribe = {
|
||||||
propertyName: 'autoSubscribe',
|
propertyName: 'autoSubscribe',
|
||||||
|
@ -167,7 +167,7 @@ var autoSubscribe = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addToSettingsSchema.push(autoSubscribe);
|
Settings.addToSchema(autoSubscribe);
|
||||||
|
|
||||||
// create new "campaign" lens for all posts from the past X days that haven't been scheduled yet
|
// create new "campaign" lens for all posts from the past X days that haven't been scheduled yet
|
||||||
viewParameters.campaign = function (terms) {
|
viewParameters.campaign = function (terms) {
|
||||||
|
@ -188,7 +188,7 @@ heroModules.push({
|
||||||
});
|
});
|
||||||
|
|
||||||
function subscribeUserOnCreation (user) {
|
function subscribeUserOnCreation (user) {
|
||||||
if (!!getSetting('autoSubscribe') && !!getEmail(user)) {
|
if (!!Settings.get('autoSubscribe') && !!getEmail(user)) {
|
||||||
addToMailChimpList(user, false, function (error, result) {
|
addToMailChimpList(user, false, function (error, result) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
console.log(result)
|
console.log(result)
|
||||||
|
|
|
@ -3,11 +3,11 @@ defaultPosts = 5;
|
||||||
|
|
||||||
getCampaignPosts = function (postsCount) {
|
getCampaignPosts = function (postsCount) {
|
||||||
|
|
||||||
var newsletterFrequency = getSetting('newsletterFrequency', defaultFrequency);
|
var newsletterFrequency = Settings.get('newsletterFrequency', defaultFrequency);
|
||||||
|
|
||||||
// look for last scheduled campaign in the database
|
// look for last scheduled campaign in the database
|
||||||
var lastCampaign = SyncedCron._collection.findOne({name: 'Schedule newsletter'}, {sort: {finishedAt: -1}, limit: 1});
|
var lastCampaign = SyncedCron._collection.findOne({name: 'Schedule newsletter'}, {sort: {finishedAt: -1}, limit: 1});
|
||||||
|
|
||||||
// if there is a last campaign use its date, else default to posts from the last 7 days
|
// if there is a last campaign use its date, else default to posts from the last 7 days
|
||||||
var lastWeek = moment().subtract(7, 'days').toDate();
|
var lastWeek = moment().subtract(7, 'days').toDate();
|
||||||
var after = (typeof lastCampaign != 'undefined') ? lastCampaign.finishedAt : lastWeek
|
var after = (typeof lastCampaign != 'undefined') ? lastCampaign.finishedAt : lastWeek
|
||||||
|
@ -43,7 +43,7 @@ buildCampaign = function (postsArray) {
|
||||||
|
|
||||||
if (post.body)
|
if (post.body)
|
||||||
properties.body = marked(trimWords(post.body, 20)).replace('<p>', '').replace('</p>', ''); // remove p tags
|
properties.body = marked(trimWords(post.body, 20)).replace('<p>', '').replace('</p>', ''); // remove p tags
|
||||||
|
|
||||||
if(post.url)
|
if(post.url)
|
||||||
properties.domain = getDomain(post.url)
|
properties.domain = getDomain(post.url)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ buildCampaign = function (postsArray) {
|
||||||
|
|
||||||
// 2. Wrap posts HTML in digest template
|
// 2. Wrap posts HTML in digest template
|
||||||
var digestHTML = getEmailTemplate('emailDigest')({
|
var digestHTML = getEmailTemplate('emailDigest')({
|
||||||
siteName: getSetting('title'),
|
siteName: Settings.get('title'),
|
||||||
date: moment().format("dddd, MMMM Do YYYY"),
|
date: moment().format("dddd, MMMM Do YYYY"),
|
||||||
content: postsHTML
|
content: postsHTML
|
||||||
});
|
});
|
||||||
|
@ -71,7 +71,7 @@ buildCampaign = function (postsArray) {
|
||||||
|
|
||||||
scheduleNextCampaign = function (isTest) {
|
scheduleNextCampaign = function (isTest) {
|
||||||
var isTest = typeof isTest === 'undefined' ? false : isTest;
|
var isTest = typeof isTest === 'undefined' ? false : isTest;
|
||||||
var posts = getCampaignPosts(getSetting('postsPerNewsletter', defaultPosts));
|
var posts = getCampaignPosts(Settings.get('postsPerNewsletter', defaultPosts));
|
||||||
if(!!posts.length){
|
if(!!posts.length){
|
||||||
return scheduleCampaign(buildCampaign(posts), isTest);
|
return scheduleCampaign(buildCampaign(posts), isTest);
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -9,7 +9,7 @@ defaultFrequency = 7; // once a week
|
||||||
defaultTime = '00:00';
|
defaultTime = '00:00';
|
||||||
|
|
||||||
var getSchedule = function (parser) {
|
var getSchedule = function (parser) {
|
||||||
var frequency = getSetting('newsletterFrequency', defaultFrequency);
|
var frequency = Settings.get('newsletterFrequency', defaultFrequency);
|
||||||
var recur = parser.recur();
|
var recur = parser.recur();
|
||||||
var schedule;
|
var schedule;
|
||||||
switch (frequency) {
|
switch (frequency) {
|
||||||
|
@ -32,7 +32,7 @@ var getSchedule = function (parser) {
|
||||||
default: // Once a week (Mondays)
|
default: // Once a week (Mondays)
|
||||||
schedule = recur.on(2).dayOfWeek();
|
schedule = recur.on(2).dayOfWeek();
|
||||||
}
|
}
|
||||||
return schedule.on(getSetting('newsletterTime', defaultTime)).time();
|
return schedule.on(Settings.get('newsletterTime', defaultTime)).time();
|
||||||
}
|
}
|
||||||
|
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
|
@ -56,7 +56,7 @@ var addJob = function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
if (getSetting('enableNewsletter', false)) {
|
if (Settings.get('enableNewsletter', false)) {
|
||||||
addJob();
|
addJob();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,8 +3,8 @@ var htmlToText = Npm.require('html-to-text');
|
||||||
scheduleCampaign = function (campaign, isTest) {
|
scheduleCampaign = function (campaign, isTest) {
|
||||||
var isTest = typeof isTest === 'undefined' ? false : isTest;
|
var isTest = typeof isTest === 'undefined' ? false : isTest;
|
||||||
|
|
||||||
var apiKey = getSetting('mailChimpAPIKey');
|
var apiKey = Settings.get('mailChimpAPIKey');
|
||||||
var listId = getSetting('mailChimpListId');
|
var listId = Settings.get('mailChimpListId');
|
||||||
|
|
||||||
if(!!apiKey && !!listId){
|
if(!!apiKey && !!listId){
|
||||||
|
|
||||||
|
@ -14,19 +14,19 @@ scheduleCampaign = function (campaign, isTest) {
|
||||||
subject = trimWords(subject, wordCount);
|
subject = trimWords(subject, wordCount);
|
||||||
wordCount--;
|
wordCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var api = new MailChimp(apiKey);
|
var api = new MailChimp(apiKey);
|
||||||
var text = htmlToText.fromString(campaign.html, {wordwrap: 130});
|
var text = htmlToText.fromString(campaign.html, {wordwrap: 130});
|
||||||
var defaultEmail = getSetting('defaultEmail');
|
var defaultEmail = Settings.get('defaultEmail');
|
||||||
var campaignOptions = {
|
var campaignOptions = {
|
||||||
type: 'regular',
|
type: 'regular',
|
||||||
options: {
|
options: {
|
||||||
list_id: listId,
|
list_id: listId,
|
||||||
subject: subject,
|
subject: subject,
|
||||||
from_email: defaultEmail,
|
from_email: defaultEmail,
|
||||||
from_name: getSetting('title')+ ' Top Posts',
|
from_name: Settings.get('title')+ ' Top Posts',
|
||||||
},
|
},
|
||||||
content: {
|
content: {
|
||||||
html: campaign.html,
|
html: campaign.html,
|
||||||
|
@ -38,7 +38,7 @@ scheduleCampaign = function (campaign, isTest) {
|
||||||
|
|
||||||
// create campaign
|
// create campaign
|
||||||
var mailchimpCampaign = api.call( 'campaigns', 'create', campaignOptions);
|
var mailchimpCampaign = api.call( 'campaigns', 'create', campaignOptions);
|
||||||
|
|
||||||
console.log( '// Campaign created');
|
console.log( '// Campaign created');
|
||||||
// console.log(campaign)
|
// console.log(campaign)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ scheduleCampaign = function (campaign, isTest) {
|
||||||
|
|
||||||
// schedule campaign
|
// schedule campaign
|
||||||
var schedule = api.call('campaigns', 'schedule', scheduleOptions);
|
var schedule = api.call('campaigns', 'schedule', scheduleOptions);
|
||||||
|
|
||||||
console.log('// Campaign scheduled for '+scheduledTime);
|
console.log('// Campaign scheduled for '+scheduledTime);
|
||||||
// console.log(schedule)
|
// console.log(schedule)
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ scheduleCampaign = function (campaign, isTest) {
|
||||||
}
|
}
|
||||||
|
|
||||||
addToMailChimpList = function(userOrEmail, confirm, done){
|
addToMailChimpList = function(userOrEmail, confirm, done){
|
||||||
|
|
||||||
var user, email;
|
var user, email;
|
||||||
|
|
||||||
var confirm = (typeof confirm === 'undefined') ? false : confirm // default to no confirmation
|
var confirm = (typeof confirm === 'undefined') ? false : confirm // default to no confirmation
|
||||||
|
@ -91,8 +91,8 @@ addToMailChimpList = function(userOrEmail, confirm, done){
|
||||||
throw 'User must have an email address';
|
throw 'User must have an email address';
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiKey = getSetting('mailChimpAPIKey');
|
var apiKey = Settings.get('mailChimpAPIKey');
|
||||||
var listId = getSetting('mailChimpListId');
|
var listId = Settings.get('mailChimpListId');
|
||||||
|
|
||||||
// add a user to a MailChimp list.
|
// add a user to a MailChimp list.
|
||||||
// called when a new user is created, or when an existing user fills in their email
|
// called when a new user is created, or when an existing user fills in their email
|
||||||
|
@ -117,7 +117,7 @@ addToMailChimpList = function(userOrEmail, confirm, done){
|
||||||
setUserSetting('subscribedToNewsletter', true, user);
|
setUserSetting('subscribedToNewsletter', true, user);
|
||||||
|
|
||||||
console.log("// User subscribed");
|
console.log("// User subscribed");
|
||||||
|
|
||||||
return subscribe;
|
return subscribe;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -143,4 +143,4 @@ Meteor.methods({
|
||||||
throw new Meteor.Error(500, error.message);
|
throw new Meteor.Error(500, error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ Meteor.startup(function () {
|
||||||
name: 'campaign',
|
name: 'campaign',
|
||||||
where: 'server',
|
where: 'server',
|
||||||
action: function() {
|
action: function() {
|
||||||
var campaign = buildCampaign(getCampaignPosts(getSetting('postsPerNewsletter', 5)));
|
var campaign = buildCampaign(getCampaignPosts(Settings.get('postsPerNewsletter', 5)));
|
||||||
var campaignSubject = '<div class="campaign-subject"><strong>Subject:</strong> '+campaign.subject+' (note: contents might change)</div>';
|
var campaignSubject = '<div class="campaign-subject"><strong>Subject:</strong> '+campaign.subject+' (note: contents might change)</div>';
|
||||||
var campaignSchedule = '<div class="campaign-schedule"><strong>Scheduled for:</strong> '+ Meteor.call('getNextJob') +'</div>';
|
var campaignSchedule = '<div class="campaign-schedule"><strong>Scheduled for:</strong> '+ Meteor.call('getNextJob') +'</div>';
|
||||||
|
|
||||||
|
@ -27,4 +27,4 @@ Meteor.startup(function () {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -13,6 +13,7 @@ Package.onUse(function (api) {
|
||||||
api.use([
|
api.use([
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'aldeed:simple-schema',
|
'aldeed:simple-schema',
|
||||||
'iron:router',
|
'iron:router',
|
||||||
'miro:mailchimp',
|
'miro:mailchimp',
|
||||||
|
|
|
@ -2,7 +2,7 @@ Template[getTemplate('notificationsMenu')].helpers({
|
||||||
menuLabel: function () {
|
menuLabel: function () {
|
||||||
var notificationsCount;
|
var notificationsCount;
|
||||||
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).fetch();
|
var notifications=Herald.collection.find({userId: Meteor.userId(), read: false}, {sort: {timestamp: -1}}).fetch();
|
||||||
|
|
||||||
if(notifications.length==0){
|
if(notifications.length==0){
|
||||||
notificationsCount = __('no_notifications');
|
notificationsCount = __('no_notifications');
|
||||||
}else if(notifications.length==1){
|
}else if(notifications.length==1){
|
||||||
|
@ -33,10 +33,10 @@ Template[getTemplate('notificationsMenu')].helpers({
|
||||||
menuMode: function () {
|
menuMode: function () {
|
||||||
if (!!this.mobile) {
|
if (!!this.mobile) {
|
||||||
return 'list';
|
return 'list';
|
||||||
} else if (getSetting('navLayout', 'top-nav') === 'top-nav') {
|
} else if (Settings.get('navLayout', 'top-nav') === 'top-nav') {
|
||||||
return 'dropdown';
|
return 'dropdown';
|
||||||
} else {
|
} else {
|
||||||
return 'accordion';
|
return 'accordion';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
// send emails every second when in dev environment
|
// send emails every second when in dev environment
|
||||||
if (Meteor.absoluteUrl().indexOf('localhost') !== -1)
|
if (Meteor.absoluteUrl().indexOf('localhost') !== -1)
|
||||||
Herald.settings.queueTimer = 1000;
|
Herald.settings.queueTimer = 1000;
|
||||||
|
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
|
|
||||||
Herald.collection.deny({
|
Herald.collection.deny({
|
||||||
|
@ -11,7 +11,7 @@ Meteor.startup(function () {
|
||||||
});
|
});
|
||||||
|
|
||||||
// disable all email notifications when "emailNotifications" is set to false
|
// disable all email notifications when "emailNotifications" is set to false
|
||||||
Herald.settings.overrides.email = !getSetting('emailNotifications', true);
|
Herald.settings.overrides.email = !Settings.get('emailNotifications', true);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,4 +176,4 @@ Herald.addCourier('newCommentSubscribed', {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
transform: commentCourierTransform
|
transform: commentCourierTransform
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,10 +8,10 @@ postAfterSubmitMethodCallbacks.push(function (post) {
|
||||||
var adminIds = _.without(adminIds, post.userId);
|
var adminIds = _.without(adminIds, post.userId);
|
||||||
var notifiedUserIds = _.without(notifiedUserIds, post.userId);
|
var notifiedUserIds = _.without(notifiedUserIds, post.userId);
|
||||||
|
|
||||||
if (post.status === STATUS_PENDING && !!adminIds.length) {
|
if (post.status === STATUS_PENDING && !!adminIds.length) {
|
||||||
// if post is pending, only notify admins
|
// if post is pending, only notify admins
|
||||||
Herald.createNotification(adminIds, {courier: 'newPendingPost', data: post});
|
Herald.createNotification(adminIds, {courier: 'newPendingPost', data: post});
|
||||||
} else if (!!notifiedUserIds.length) {
|
} else if (!!notifiedUserIds.length) {
|
||||||
// if post is approved, notify everybody
|
// if post is approved, notify everybody
|
||||||
Herald.createNotification(notifiedUserIds, {courier: 'newPost', data: post});
|
Herald.createNotification(notifiedUserIds, {courier: 'newPost', data: post});
|
||||||
}
|
}
|
||||||
|
@ -47,24 +47,24 @@ commentAfterSubmitMethodCallbacks.push(function (comment) {
|
||||||
|
|
||||||
// 2. Notify author of comment being replied to
|
// 2. Notify author of comment being replied to
|
||||||
if (!!comment.parentCommentId) {
|
if (!!comment.parentCommentId) {
|
||||||
|
|
||||||
var parentComment = Comments.findOne(comment.parentCommentId);
|
var parentComment = Comments.findOne(comment.parentCommentId);
|
||||||
|
|
||||||
// do not notify author of parent comment if they're also post author or comment author
|
// do not notify author of parent comment if they're also post author or comment author
|
||||||
// (someone could be replying to their own comment)
|
// (someone could be replying to their own comment)
|
||||||
if (parentComment.userId !== post.userId && parentComment.userId !== comment.userId) {
|
if (parentComment.userId !== post.userId && parentComment.userId !== comment.userId) {
|
||||||
|
|
||||||
// add parent comment to notification data
|
// add parent comment to notification data
|
||||||
notificationData.parentComment = _.pick(parentComment, '_id', 'userId', 'author');
|
notificationData.parentComment = _.pick(parentComment, '_id', 'userId', 'author');
|
||||||
|
|
||||||
Herald.createNotification(parentComment.userId, {courier: 'newReply', data: notificationData});
|
Herald.createNotification(parentComment.userId, {courier: 'newReply', data: notificationData});
|
||||||
userIdsNotified.push(parentComment.userId);
|
userIdsNotified.push(parentComment.userId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Notify users subscribed to the thread
|
// 3. Notify users subscribed to the thread
|
||||||
// TODO: ideally this would be injected from the telescope-subscribe-to-posts package
|
// TODO: ideally this would be injected from the telescope-subscribe-to-posts package
|
||||||
if (!!post.subscribers) {
|
if (!!post.subscribers) {
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ commentAfterSubmitMethodCallbacks.push(function (comment) {
|
||||||
Herald.createNotification(subscriberIdsToNotify, {courier: 'newCommentSubscribed', data: notificationData});
|
Herald.createNotification(subscriberIdsToNotify, {courier: 'newCommentSubscribed', data: notificationData});
|
||||||
|
|
||||||
userIdsNotified = userIdsNotified.concat(subscriberIdsToNotify);
|
userIdsNotified = userIdsNotified.concat(subscriberIdsToNotify);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ var emailNotifications = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
addToSettingsSchema.push(emailNotifications);
|
Settings.addToSchema(emailNotifications);
|
||||||
|
|
||||||
// make it possible to disable notifications on a per-comment basis
|
// make it possible to disable notifications on a per-comment basis
|
||||||
addToCommentsSchema.push(
|
addToCommentsSchema.push(
|
||||||
|
|
|
@ -9,6 +9,7 @@ Package.onUse(function (api) {
|
||||||
api.use([
|
api.use([
|
||||||
'telescope-lib',
|
'telescope-lib',
|
||||||
'telescope-base',
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
'telescope-email',
|
'telescope-email',
|
||||||
'iron:router',
|
'iron:router',
|
||||||
'kestanous:herald@1.3.0',
|
'kestanous:herald@1.3.0',
|
||||||
|
@ -51,7 +52,7 @@ Package.onUse(function (api) {
|
||||||
'lib/server/notifications-server.js',
|
'lib/server/notifications-server.js',
|
||||||
'lib/server/routes.js'
|
'lib/server/routes.js'
|
||||||
], ['server']);
|
], ['server']);
|
||||||
|
|
||||||
api.add_files([
|
api.add_files([
|
||||||
"i18n/de.i18n.json",
|
"i18n/de.i18n.json",
|
||||||
"i18n/en.i18n.json",
|
"i18n/en.i18n.json",
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
var RSS = Npm.require('rss');
|
var RSS = Npm.require('rss');
|
||||||
|
|
||||||
var getMeta = function(url) {
|
var getMeta = function(url) {
|
||||||
var siteUrl = getSetting('siteUrl', Meteor.absoluteUrl());
|
var siteUrl = Settings.get('siteUrl', Meteor.absoluteUrl());
|
||||||
return {
|
return {
|
||||||
title: getSetting('title'),
|
title: Settings.get('title'),
|
||||||
description: getSetting('tagline'),
|
description: Settings.get('tagline'),
|
||||||
feed_url: siteUrl+url,
|
feed_url: siteUrl+url,
|
||||||
site_url: siteUrl,
|
site_url: siteUrl,
|
||||||
image_url: siteUrl+'img/favicon.png',
|
image_url: siteUrl+'img/favicon.png',
|
||||||
|
|
|
@ -4,9 +4,13 @@ Npm.depends({rss: "0.3.2"});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function (api) {
|
||||||
|
|
||||||
api.use(['telescope-base', 'telescope-lib'], ['server']);
|
api.use([
|
||||||
|
'telescope-base',
|
||||||
|
'telescope-lib',
|
||||||
|
'telescope-settings'
|
||||||
|
], ['server']);
|
||||||
|
|
||||||
api.add_files(['lib/server/rss.js', 'lib/server/routes.js'], ['server']);
|
api.add_files(['lib/server/rss.js', 'lib/server/routes.js'], ['server']);
|
||||||
|
|
||||||
api.export(['serveRSS']);
|
api.export(['serveRSS']);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,10 +4,10 @@ Meteor.startup(function () {
|
||||||
view: 'search',
|
view: 'search',
|
||||||
showViewsNav: false,
|
showViewsNav: false,
|
||||||
getTitle: function() {
|
getTitle: function() {
|
||||||
return i18n.t("Search") + ' - ' + getSetting('title', "Telescope");
|
return i18n.t("Search") + ' - ' + Settings.get('title', "Telescope");
|
||||||
},
|
},
|
||||||
getDescription: function() {
|
getDescription: function() {
|
||||||
return getSetting('description');
|
return Settings.get('description');
|
||||||
},
|
},
|
||||||
onBeforeAction: function() {
|
onBeforeAction: function() {
|
||||||
var query = this.params.query;
|
var query = this.params.query;
|
||||||
|
|
|
@ -2,7 +2,12 @@ Package.describe({summary: "Telescope search package"});
|
||||||
|
|
||||||
Package.onUse(function (api) {
|
Package.onUse(function (api) {
|
||||||
|
|
||||||
api.use(['telescope-lib', 'telescope-base', 'aldeed:simple-schema'], ['client', 'server']);
|
api.use([
|
||||||
|
'telescope-lib',
|
||||||
|
'telescope-base',
|
||||||
|
'telescope-settings',
|
||||||
|
'aldeed:simple-schema'
|
||||||
|
], ['client', 'server']);
|
||||||
|
|
||||||
api.use([
|
api.use([
|
||||||
'jquery',
|
'jquery',
|
||||||
|
@ -42,4 +47,4 @@ Package.onUse(function (api) {
|
||||||
], ["client", "server"]);
|
], ["client", "server"]);
|
||||||
|
|
||||||
api.export(['adminMenu', 'viewParameters']);
|
api.export(['adminMenu', 'viewParameters']);
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,7 @@ Meteor.startup(function() {
|
||||||
var props = {meta: {}, og: {}};
|
var props = {meta: {}, og: {}};
|
||||||
var title = this.getTitle && this.getTitle();
|
var title = this.getTitle && this.getTitle();
|
||||||
var description = this.getDescription && this.getDescription();
|
var description = this.getDescription && this.getDescription();
|
||||||
var image = getSetting("siteImage");
|
var image = Settings.get("siteImage");
|
||||||
if (title) {
|
if (title) {
|
||||||
props.og.title = title;
|
props.og.title = title;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Add SEO settings.
|
// Add SEO settings.
|
||||||
addToSettingsSchema.push({
|
Settings.addToSchema({
|
||||||
propertyName: "siteImage",
|
propertyName: "siteImage",
|
||||||
propertySchema: {
|
propertySchema: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -10,4 +10,4 @@ addToSettingsSchema.push({
|
||||||
instructions: "URL to an image for the open graph image tag for all pages"
|
instructions: "URL to an image for the open graph image tag for all pages"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -16,7 +16,7 @@ Meteor.startup(function() {
|
||||||
|
|
||||||
// Posts list pages
|
// Posts list pages
|
||||||
var paths = [
|
var paths = [
|
||||||
{page: "/", lastmod: _getLatest(getSetting("defaultView", "top")), changefreq: "hourly"},
|
{page: "/", lastmod: _getLatest(Settings.get("defaultView", "top")), changefreq: "hourly"},
|
||||||
{page: "/top", lastmod: _getLatest("top"), changefreq: "hourly"},
|
{page: "/top", lastmod: _getLatest("top"), changefreq: "hourly"},
|
||||||
{page: "/new", lastmod: _getLatest("new"), changefreq: "hourly"},
|
{page: "/new", lastmod: _getLatest("new"), changefreq: "hourly"},
|
||||||
{page: "/best", lastmod: _getLatest("best"), changefreq: "daily"},
|
{page: "/best", lastmod: _getLatest("best"), changefreq: "daily"},
|
||||||
|
|
|
@ -13,6 +13,7 @@ Package.onUse(function(api) {
|
||||||
"iron:router",
|
"iron:router",
|
||||||
"telescope-lib",
|
"telescope-lib",
|
||||||
"telescope-base",
|
"telescope-base",
|
||||||
|
"telescope-settings",
|
||||||
"telescope-i18n",
|
"telescope-i18n",
|
||||||
"manuelschoebel:ms-seo@0.4.1",
|
"manuelschoebel:ms-seo@0.4.1",
|
||||||
"gadicohen:sitemaps@0.0.20"
|
"gadicohen:sitemaps@0.0.20"
|
||||||
|
|
6
packages/telescope-settings/lib/client/helpers.js
Normal file
6
packages/telescope-settings/lib/client/helpers.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
/* global Settings: false */
|
||||||
|
|
||||||
|
Template.registerHelper('getSetting', function(setting, defaultArgument){
|
||||||
|
setting = Settings.get(setting, defaultArgument);
|
||||||
|
return setting;
|
||||||
|
});
|
12
packages/telescope-settings/lib/client/language_changer.js
Normal file
12
packages/telescope-settings/lib/client/language_changer.js
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
var query = Settings.collection.find();
|
||||||
|
|
||||||
|
query.observeChanges({
|
||||||
|
added: function (id, fields) {
|
||||||
|
if (fields.language)
|
||||||
|
setLanguage(fields.language);
|
||||||
|
},
|
||||||
|
changed: function (id, fields) {
|
||||||
|
if (fields.language)
|
||||||
|
setLanguage(fields.language);
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,7 @@
|
||||||
|
<template name="settings">
|
||||||
|
{{#if this.hasSettings}}
|
||||||
|
{{> quickForm collection="Settings.collection" id="updateSettingsForm" type="update" doc=this.settings label-class="control-label" input-col-class="controls" template="telescope"}}
|
||||||
|
{{else}}
|
||||||
|
{{> quickForm collection="Settings.collection" id="insertSettingsForm" type="insert" template="telescope" label-class="control-label" input-col-class="controls"}}
|
||||||
|
{{/if}}
|
||||||
|
</template>
|
|
@ -1,13 +1,4 @@
|
||||||
AutoForm.hooks({
|
AutoForm.addHooks(['updateSettingsForm', 'insertSettingsForm'], {
|
||||||
updateSettingsForm: {
|
|
||||||
|
|
||||||
before: {
|
|
||||||
update: function(modifier) {
|
|
||||||
this.template.$('button[type=submit]').addClass('loading');
|
|
||||||
return modifier;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
onSuccess: function(operation, result) {
|
onSuccess: function(operation, result) {
|
||||||
this.template.$('button[type=submit]').removeClass('loading');
|
this.template.$('button[type=submit]').removeClass('loading');
|
||||||
},
|
},
|
||||||
|
@ -15,24 +6,24 @@ AutoForm.hooks({
|
||||||
onError: function(operation, result, template) {
|
onError: function(operation, result, template) {
|
||||||
this.template.$('button[type=submit]').removeClass('loading');
|
this.template.$('button[type=submit]').removeClass('loading');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
AutoForm.hooks({
|
||||||
|
updateSettingsForm: {
|
||||||
|
before: {
|
||||||
|
update: function(modifier) {
|
||||||
|
this.template.$('button[type=submit]').addClass('loading');
|
||||||
|
return modifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
insertSettingsForm: {
|
insertSettingsForm: {
|
||||||
|
|
||||||
before: {
|
before: {
|
||||||
insert: function(doc) {
|
insert: function(doc) {
|
||||||
this.template.$('button[type=submit]').addClass('loading');
|
this.template.$('button[type=submit]').addClass('loading');
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
onSuccess: function(operation, result) {
|
|
||||||
this.template.$('button[type=submit]').removeClass('loading');
|
|
||||||
},
|
|
||||||
|
|
||||||
onError: function(operation, result) {
|
|
||||||
this.template.$('button[type=submit]').removeClass('loading');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
18
packages/telescope-settings/lib/router.js
Normal file
18
packages/telescope-settings/lib/router.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
Meteor.startup(function () {
|
||||||
|
// Settings
|
||||||
|
|
||||||
|
Router.route('/settings', {
|
||||||
|
controller: AdminController,
|
||||||
|
name: 'settings',
|
||||||
|
// layoutTemplate: getTemplate('adminLayout'),
|
||||||
|
data: function () {
|
||||||
|
// we only have one set of settings for now
|
||||||
|
|
||||||
|
var settings = Settings.collection.findOne();
|
||||||
|
return {
|
||||||
|
hasSettings: !!settings,
|
||||||
|
settings: settings
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -2,8 +2,8 @@ Meteor.publish('settings', function() {
|
||||||
var options = {};
|
var options = {};
|
||||||
var privateFields = {};
|
var privateFields = {};
|
||||||
|
|
||||||
// look at SettingsSchema to see which fields should be kept private
|
// look at Settings.schema to see which fields should be kept private
|
||||||
_.each(SettingsSchema._schema, function( val, key ) {
|
_.each(Settings.schema._schema, function( val, key ) {
|
||||||
if (val.autoform && !!val.autoform.private)
|
if (val.autoform && !!val.autoform.private)
|
||||||
privateFields[key] = false;
|
privateFields[key] = false;
|
||||||
});
|
});
|
||||||
|
@ -13,5 +13,6 @@ Meteor.publish('settings', function() {
|
||||||
fields: privateFields
|
fields: privateFields
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return Settings.find({}, options);
|
|
||||||
});
|
return Settings.collection.find({}, options);
|
||||||
|
});
|
|
@ -1,4 +1,8 @@
|
||||||
settingsSchemaObject = {
|
Settings = {
|
||||||
|
collection: new Meteor.Collection("settings")
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings.schema = new SimpleSchema({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
@ -84,7 +88,7 @@ settingsSchemaObject = {
|
||||||
instructions: 'MAIL_URL environment variable (requires restart).',
|
instructions: 'MAIL_URL environment variable (requires restart).',
|
||||||
private: true
|
private: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scoreUpdateInterval: {
|
scoreUpdateInterval: {
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
@ -136,7 +140,7 @@ settingsSchemaObject = {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
postInterval: {
|
postInterval: {
|
||||||
type: Number,
|
type: Number,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
@ -379,46 +383,55 @@ settingsSchemaObject = {
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
instructions: 'Authentication methods (default to email only)'
|
instructions: 'Authentication methods (default to email only)'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
// add any extra properties to settingsSchemaObject (provided by packages for example)
|
|
||||||
_.each(addToSettingsSchema, function(item){
|
|
||||||
settingsSchemaObject[item.propertyName] = item.propertySchema;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Settings = new Meteor.Collection("settings");
|
Settings.collection.attachSchema(Settings.schema);
|
||||||
SettingsSchema = new SimpleSchema(settingsSchemaObject);
|
|
||||||
Settings.attachSchema(SettingsSchema);
|
Settings.addToSchema = function(item) {
|
||||||
|
var itemSchema = {};
|
||||||
|
itemSchema[item.propertyName] = item.propertySchema;
|
||||||
|
|
||||||
|
Settings.collection.attachSchema(itemSchema);
|
||||||
|
Settings.schema = new SimpleSchema(Settings.schema, itemSchema);
|
||||||
|
};
|
||||||
|
|
||||||
|
Settings.get = function(setting, defaultValue) {
|
||||||
|
var settings = Settings.collection.find().fetch()[0];
|
||||||
|
|
||||||
|
if (Meteor.isServer && Meteor.settings && !!Meteor.settings[setting]) { // if on the server, look in Meteor.settings
|
||||||
|
return Meteor.settings[setting];
|
||||||
|
|
||||||
|
} else if (Meteor.settings && Meteor.settings.public && !!Meteor.settings.public[setting]) { // look in Meteor.settings.public
|
||||||
|
return Meteor.settings.public[setting];
|
||||||
|
|
||||||
|
} else if(settings && (typeof settings[setting] !== 'undefined')) { // look in Settings collection
|
||||||
|
return settings[setting];
|
||||||
|
|
||||||
|
} else if (typeof defaultValue !== 'undefined') { // fallback to default
|
||||||
|
return defaultValue;
|
||||||
|
|
||||||
|
} else { // or return undefined
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// use custom template for checkboxes - not working yet
|
// use custom template for checkboxes - not working yet
|
||||||
// if(Meteor.isClient){
|
// if(Meteor.isClient){
|
||||||
// AutoForm.setDefaultTemplateForType('afCheckbox', 'settings');
|
// AutoForm.setDefaultTemplateForType('afCheckbox', 'settings');
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Settings.allow({
|
Meteor.startup(function () {
|
||||||
insert: isAdminById,
|
Settings.collection.allow({
|
||||||
update: isAdminById,
|
insert: isAdminById,
|
||||||
remove: isAdminById
|
update: isAdminById,
|
||||||
});
|
remove: isAdminById
|
||||||
|
|
||||||
if (Meteor.isClient){
|
|
||||||
var query = Settings.find();
|
|
||||||
var handle = query.observeChanges({
|
|
||||||
added: function (id, fields) {
|
|
||||||
if (fields.language)
|
|
||||||
setLanguage(fields.language)
|
|
||||||
},
|
|
||||||
changed: function (id, fields) {
|
|
||||||
if (fields.language)
|
|
||||||
setLanguage(fields.language)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
// override Meteor.absoluteUrl() with URL provided in settings
|
// override Meteor.absoluteUrl() with URL provided in settings
|
||||||
Meteor.absoluteUrl.defaultOptions.rootUrl = getSetting('siteUrl', Meteor.absoluteUrl());
|
Meteor.absoluteUrl.defaultOptions.rootUrl = Settings.get('siteUrl', Meteor.absoluteUrl());
|
||||||
debug = getSetting('debug', false);
|
debug = Settings.get('debug', false);
|
||||||
});
|
});
|
38
packages/telescope-settings/package.js
Normal file
38
packages/telescope-settings/package.js
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
Package.describe({summary: "Telescope settings package"});
|
||||||
|
|
||||||
|
Package.onUse(function(api) {
|
||||||
|
var both = ['server', 'client'];
|
||||||
|
|
||||||
|
api.use([
|
||||||
|
'mongo',
|
||||||
|
'underscore',
|
||||||
|
|
||||||
|
'aldeed:simple-schema',
|
||||||
|
|
||||||
|
'telescope-base',
|
||||||
|
'telescope-lib'
|
||||||
|
], both);
|
||||||
|
|
||||||
|
api.use([
|
||||||
|
'templating',
|
||||||
|
'aldeed:autoform'
|
||||||
|
], 'client');
|
||||||
|
|
||||||
|
api.addFiles([
|
||||||
|
'lib/settings.js',
|
||||||
|
'lib/router.js'
|
||||||
|
], both);
|
||||||
|
|
||||||
|
api.addFiles([
|
||||||
|
'lib/server/publications.js',
|
||||||
|
], 'server');
|
||||||
|
|
||||||
|
api.addFiles([
|
||||||
|
'lib/client/language_changer.js',
|
||||||
|
'lib/client/helpers.js',
|
||||||
|
'lib/client/templates/settings_form.html',
|
||||||
|
'lib/client/templates/settings_form.js'
|
||||||
|
], 'client');
|
||||||
|
|
||||||
|
api.export('Settings', both);
|
||||||
|
});
|
|
@ -11,7 +11,7 @@ Template[getTemplate('singleDay')].created = function () {
|
||||||
|
|
||||||
// initialize the reactive variables
|
// initialize the reactive variables
|
||||||
instance.postsLoaded = new ReactiveVar(0);
|
instance.postsLoaded = new ReactiveVar(0);
|
||||||
instance.postsLimit = new ReactiveVar(getSetting('postsPerPage', 10));
|
instance.postsLimit = new ReactiveVar(Settings.get('postsPerPage', 10));
|
||||||
instance.postsReady = new ReactiveVar(false);
|
instance.postsReady = new ReactiveVar(false);
|
||||||
|
|
||||||
instance.getTerms = function () {
|
instance.getTerms = function () {
|
||||||
|
@ -31,7 +31,7 @@ Template[getTemplate('singleDay')].created = function () {
|
||||||
instance.autorun(function () {
|
instance.autorun(function () {
|
||||||
// just by including this session variable in the autorun, we automatically make it depend on it
|
// just by including this session variable in the autorun, we automatically make it depend on it
|
||||||
var currentDate = Session.get('currentDate');
|
var currentDate = Session.get('currentDate');
|
||||||
instance.postsLimit.set(getSetting('postsPerPage', 10));
|
instance.postsLimit.set(Settings.get('postsPerPage', 10));
|
||||||
});
|
});
|
||||||
|
|
||||||
// will re-run when postsLimit or currentDate change
|
// will re-run when postsLimit or currentDate change
|
||||||
|
@ -107,7 +107,7 @@ Template[getTemplate('singleDay')].helpers({
|
||||||
// get current value for limit, i.e. how many posts are currently displayed
|
// get current value for limit, i.e. how many posts are currently displayed
|
||||||
var limit = instance.postsLimit.get();
|
var limit = instance.postsLimit.get();
|
||||||
// increase limit by 5 and update it
|
// increase limit by 5 and update it
|
||||||
limit += getSetting('postsPerPage', 10);
|
limit += Settings.get('postsPerPage', 10);
|
||||||
instance.postsLimit.set(limit);
|
instance.postsLimit.set(limit);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -118,4 +118,4 @@ Template[getTemplate('singleDay')].helpers({
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,14 +8,14 @@ PostsSingledayController = RouteController.extend({
|
||||||
this.render(getTemplate('postListTop'), {to: 'postListTop'});
|
this.render(getTemplate('postListTop'), {to: 'postListTop'});
|
||||||
this.next();
|
this.next();
|
||||||
},
|
},
|
||||||
|
|
||||||
data: function() {
|
data: function() {
|
||||||
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today');
|
var currentDate = this.params.day ? new Date(this.params.year, this.params.month-1, this.params.day) : Session.get('today');
|
||||||
Session.set('currentDate', currentDate);
|
Session.set('currentDate', currentDate);
|
||||||
},
|
},
|
||||||
|
|
||||||
getTitle: function () {
|
getTitle: function () {
|
||||||
return i18n.t('single_day') + ' - ' + getSetting('title', 'Telescope');
|
return i18n.t('single_day') + ' - ' + Settings.get('title', 'Telescope');
|
||||||
},
|
},
|
||||||
|
|
||||||
getDescription: function () {
|
getDescription: function () {
|
||||||
|
@ -40,4 +40,4 @@ Meteor.startup(function () {
|
||||||
controller: PostsSingledayController
|
controller: PostsSingledayController
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
Template[getTemplate('taglineBanner')].helpers({
|
Template[getTemplate('taglineBanner')].helpers({
|
||||||
showTaglineBanner: function () {
|
showTaglineBanner: function () {
|
||||||
return !!getSetting('tagline') && !!getSetting('showTaglineBanner');
|
return !!Settings.get('tagline') && !!Settings.get('showTaglineBanner');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,5 +14,5 @@ var showTaglineBanner = {
|
||||||
instructions: 'Show tagline on homepage.'
|
instructions: 'Show tagline on homepage.'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
addToSettingsSchema.push(showTaglineBanner);
|
Settings.addToSchema(showTaglineBanner);
|
||||||
|
|
|
@ -13,6 +13,7 @@ Package.onUse(function (api) {
|
||||||
api.use([
|
api.use([
|
||||||
'telescope-base', // basic Telescope hooks and objects
|
'telescope-base', // basic Telescope hooks and objects
|
||||||
'telescope-lib', // useful functions
|
'telescope-lib', // useful functions
|
||||||
|
'telescope-settings',
|
||||||
'fourseven:scss', // SCSS compilation package
|
'fourseven:scss', // SCSS compilation package
|
||||||
'tap:i18n'
|
'tap:i18n'
|
||||||
]);
|
]);
|
||||||
|
@ -45,4 +46,4 @@ Package.onUse(function (api) {
|
||||||
"i18n/en.i18n.json"
|
"i18n/en.i18n.json"
|
||||||
], ["client", "server"]);
|
], ["client", "server"]);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -19,11 +19,11 @@ Meteor.startup(function () {
|
||||||
menuMode: function () {
|
menuMode: function () {
|
||||||
if (!!this.mobile) {
|
if (!!this.mobile) {
|
||||||
return 'list';
|
return 'list';
|
||||||
} else if (getSetting('navLayout', 'top-nav') === 'top-nav') {
|
} else if (Settings.get('navLayout', 'top-nav') === 'top-nav') {
|
||||||
return 'dropdown';
|
return 'dropdown';
|
||||||
} else {
|
} else {
|
||||||
return 'accordion';
|
return 'accordion';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
phoneHome: function () {
|
phoneHome: function () {
|
||||||
|
|
||||||
var url = 'http://version.telescopeapp.org/';
|
var url = 'http://version.telescopeapp.org/';
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
currentVersion: telescopeVersion,
|
currentVersion: telescopeVersion,
|
||||||
siteTitle: getSetting('title'),
|
siteTitle: Settings.get('title'),
|
||||||
siteUrl: getSiteUrl(),
|
siteUrl: getSiteUrl(),
|
||||||
users: Meteor.users.find().count(),
|
users: Meteor.users.find().count(),
|
||||||
posts: Posts.find().count(),
|
posts: Posts.find().count(),
|
||||||
|
@ -26,4 +26,4 @@ Meteor.methods({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -497,7 +497,7 @@ var migrationsList = {
|
||||||
},
|
},
|
||||||
changeColorNames: function () {
|
changeColorNames: function () {
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var settings = Settings.findOne();
|
var settings = Settings.collection.findOne();
|
||||||
var set = {};
|
var set = {};
|
||||||
|
|
||||||
if (!!settings) {
|
if (!!settings) {
|
||||||
|
@ -513,7 +513,7 @@ var migrationsList = {
|
||||||
|
|
||||||
if (!!settings.buttonColor)
|
if (!!settings.buttonColor)
|
||||||
set.secondaryContrastColor = settings.headerTextColor;
|
set.secondaryContrastColor = settings.headerTextColor;
|
||||||
|
|
||||||
if (!_.isEmpty(set)) {
|
if (!_.isEmpty(set)) {
|
||||||
Settings.update(settings._id, {$set: set}, {validate: false});
|
Settings.update(settings._id, {$set: set}, {validate: false});
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ Meteor.publish('currentUser', function() {
|
||||||
// TODO: find a better way
|
// TODO: find a better way
|
||||||
|
|
||||||
Meteor.publish('allUsersAdmin', function() {
|
Meteor.publish('allUsersAdmin', function() {
|
||||||
var selector = getSetting('requirePostInvite') ? {isInvited: true} : {}; // only users that can post
|
var selector = Settings.get('requirePostInvite') ? {isInvited: true} : {}; // only users that can post
|
||||||
if (isAdminById(this.userId)) {
|
if (isAdminById(this.userId)) {
|
||||||
return Meteor.users.find(selector, {fields: {
|
return Meteor.users.find(selector, {fields: {
|
||||||
_id: true,
|
_id: true,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
var scoreInterval = getSetting("scoreUpdateInterval") || 30;
|
var scoreInterval = Settings.get("scoreUpdateInterval") || 30;
|
||||||
if (scoreInterval > 0) {
|
if (scoreInterval > 0) {
|
||||||
|
|
||||||
// active items get updated every N seconds
|
// active items get updated every N seconds
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
Meteor.startup(function () {
|
Meteor.startup(function () {
|
||||||
logEvent({
|
logEvent({
|
||||||
name: "firstRun",
|
name: "firstRun",
|
||||||
unique: true, // will only get logged a single time
|
unique: true, // will only get logged a single time
|
||||||
important: true
|
important: true
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if (getSetting('mailUrl'))
|
if (Settings.get('mailUrl'))
|
||||||
process.env.MAIL_URL = getSetting('mailUrl');
|
process.env.MAIL_URL = Settings.get('mailUrl');
|
||||||
|
|
|
@ -27,7 +27,7 @@ describe('test nav template', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the logo from the setting', function () {
|
it('should render the logo from the setting', function () {
|
||||||
spyOn(window, 'getSetting').and.callFake(function (settingName) {
|
spyOn(window, 'Settings.get').and.callFake(function (settingName) {
|
||||||
return settingName;
|
return settingName;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ describe('test nav template', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should render the site title if logo_url setting is empty', function () {
|
it('should render the site title if logo_url setting is empty', function () {
|
||||||
spyOn(window, 'getSetting').and.callFake(function (settingName) {
|
spyOn(window, 'Settings.get').and.callFake(function (settingName) {
|
||||||
if (settingName === 'logoUrl') {
|
if (settingName === 'logoUrl') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -231,4 +231,4 @@ describe('test nav template', function() {
|
||||||
expect(renderedSecondaryNav.length).toEqual(1);
|
expect(renderedSecondaryNav.length).toEqual(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue