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