Merge branch 'master' of https://github.com/TelescopeJS/Telescope into telescope-master-seo2

This commit is contained in:
Charlie DeTar 2014-12-16 09:04:47 -07:00
commit 46b7a3af34
8 changed files with 314 additions and 212 deletions

24
.editorconfig Normal file
View file

@ -0,0 +1,24 @@
# editorconfig.org
root = true
[*.js]
# Change these settings to your own preference
indent_style = space
indent_size = 2
# We recommend you to keep these unchanged
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 80
indent_brace_style = 1TBS
spaces_around_operators = true
quote_type = auto
[*.md]
trim_trailing_whitespace = false

View file

@ -75,7 +75,7 @@ telescope-singleday
telescope-invites
# Accounts Templates
useraccounts:unstyled
useraccounts:unstyled@1.4.0
telescope-datetimepicker
tsega:bootstrap3-datetimepicker@3.1.3_1

View file

@ -101,7 +101,7 @@ sacha:spin@2.0.4
service-configuration@1.0.2
session@1.0.4
sha@1.0.1
softwarerero:accounts-t9n@1.0.2
softwarerero:accounts-t9n@1.0.4
spacebars-compiler@1.0.3
spacebars@1.0.3
spiderable@1.0.5
@ -137,7 +137,7 @@ twitter@1.1.2
ui@1.0.4
underscore@1.0.1
url@1.0.2
useraccounts:core@1.3.2
useraccounts:unstyled@1.3.2
useraccounts:core@1.4.0
useraccounts:unstyled@1.4.0
webapp-hashing@1.0.1
webapp@1.1.4

View file

@ -38,19 +38,19 @@
<div class="controls"><textarea name="bio" type="text">{{profile.bio}}</textarea></div>
</div>
<div class="control-group">
<label>Twitter Username</label>
<label>{{_ "twitter_username"}}</label>
<div class="controls">
<input name="twitter" type="text" value="{{getTwitter}}" />
</div>
</div>
<div class="control-group">
<label>GitHub Username</label>
<label>{{_ "github_username"}}</label>
<div class="controls">
<input name="github" type="text" value="{{getGitHub}}" />
</div>
</div>
<div class="control-group">
<label>Site</label>
<label>{{_ "site_url"}}</label>
<div class="controls">
<input name="site" type="text" value="{{profile.site}}" />
</div>
@ -71,7 +71,7 @@
<div class="controls">
{{#if isAdmin}}
<label class="checkbox">
<input id="notifications_users" type="checkbox" name="notifications_users" {{hasNotificationsUsers}} /> New Users
<input id="notifications_users" type="checkbox" name="notifications_users" {{hasNotificationsUsers}} /> {{_ "new_users"}}
</label>
{{/if}}
<label class="checkbox">

View file

@ -162,18 +162,22 @@
"point": "point",
"points": "points",
//User
//User /client/views/users/account/user_account.html
"please_complete_your_profile_below_before_continuing": "Please complete your profile below before continuing.",
"account": "Account",
"username": "Username",
"display_name": "Display Name",
"email": "Email",
"bio": "Bio",
"twitter_username": "Twitter Username",
"github_username": "GitHub Username",
"site_url" : "Site URL",
"password": "Password",
"change_password": "Change Password?",
"old_password": "Old Password",
"new_password": "New Password",
"email_notifications": "Email Notifications",
"new_users" : "New users",
"new_posts": "New Posts",
"comments_on_my_posts": "Comments on my posts",
"replies_to_my_comments": "Replies to my comments",

View file

@ -8,9 +8,9 @@
"digest": "Дайджест",
"users": "Пользователи",
"settings": "Настройки",
"admin": "Админ",
"admin": "Админка",
"post": "Пост",
"toolbox": "Toolbox",
"toolbox": "Инструменты",
"sign_up_sign_in": "Вход/Регистрация",
"my_account": "Мой аккаунт",
"view_profile": "Просмотр профиля",
@ -19,191 +19,268 @@
//Main
"new_posts": "Новые посты",
//Commments
"your_comment_has_been_deleted": "Ваш комментарий удален.",
// Settings Schema
"title": "Название",
"siteUrl": "URL сайта",
"tagline": "Теги",
"requireViewInvite": "Требуется инвайт для Вида",
"requirePostInvite": "Требуется инвайт для поста",
"requirePostsApproval": "Нужно утвердить посты",
"defaultEmail": "Email по-умолчанию",
"scoreUpdateInterval": "Интервал обновления очков",
"defaultView": "Вид по-умолчанию",
"postInterval": "Интервал между постами",
"commentInterval": "Интервал между комментариями",
"maxPostsPerDay": "Максимум постов за день",
"startInvitesCount": "Приглашает к старту счёта",
"postsPerPage": "Постов на странице",
"logoUrl": "URL лого",
"logoHeight": "Высота лого",
"logoWidth": "Ширина лого",
"language": "Язык",
"backgroundCSS": "CSS фона",
"buttonColor": "Цвет кнопок",
"buttonTextColor": "Цвет текста кнопок",
"headerColor": "Цвет заголовка",
"headerTextColor": "Цвет текста заголовка",
"twitterAccount": "Twitter аккаунт",
"googleAnalyticsId": "Google Analytics ID",
"mixpanelId": "Mixpanel ID",
"clickyId": "Clicky ID",
"footerCode": "Код футера",
"extraCode": "Дополнительный код",
"emailFooter": "Email футер",
"notes": "Замечания",
"debug": "Режим отладки",
// Settings Fieldsets
"general": "Главная",
"invites": "Инвайты",
"email": "Email",
"scoring": "Очки",
"posts": "Посты",
"comments": "Комментарии",
"logo": "Лого",
"extras": "Дополнения",
"colors": "Цвета",
"integrations": "Интеграции",
// Settings Help Text
// Post Schema
"createdAt": "Создан",
"postedAt": "Опубликован",
"url": "URL",
"title": "название",
"body": "Body",
"htmlBody": "HTML Body",
"viewCount": "Просмотров",
"commentCount": "Комментариве",
"commenters": "Комментаторов",
"lastCommentedAt": "Последний комментарий",
"clickCount": "Кликов",
"baseScore": "Базовый счёт",
"upvotes": "Голосов За",
"upvoters": "Поддержали",
"downvotes": "Голосов Против",
"downvoters": "Выступили против",
"score": "Счёт",
"status": "Статус",
"sticky": "Прилепило",
"inactive": "Неактивно",
"author": "Автор",
"userId": "Пользователь",
//Comments
"your_comment_has_been_deleted": "Ваш комментарий удалили.",
"comment_": "Комментарий",
"delete_comment": "Удалить комментарий",
"add_comment": "Добавить комментарий",
"upvote": "за",
"downvote": "против",
"link": "ссылка",
"edit": "Редактирование",
"edit": "Редактировать",
"reply": "Ответить",
"no_comments": "Нет комментариев.",
"no_comments": "Без комментариев.",
//Errors
"you_are_already_logged_in": "You are already logged in",
"sorry_this_is_a_private_site_please_sign_up_first": "Sorry, this is a private site. Please sign up first.",
"you_are_already_logged_in": "Вы уже вошли",
"sorry_this_is_a_private_site_please_sign_up_first": "Извините, это частный сайт. Вначале зарегистрируйтесь.",
"thanks_for_signing_up": "Thanks for signing up!",
"the_site_is_currently_invite_only_but_we_will_let_you_know_as_soon_as_a_spot_opens_up": "The site is currently invite-only, but we will let you know as soon as a spot opens up.",
"sorry_you_dont_have_the_rights_to_view_this_page": "Sorry, you don't have the rights to view this page.",
"the_site_is_currently_invite_only_but_we_will_let_you_know_as_soon_as_a_spot_opens_up": "Сайт пока что только по инвайтам, но мы вам сообщим, если будет открыта регистрация.",
"sorry_you_dont_have_the_rights_to_view_this_page": "Извините, но у вас нет прав для просмотра страницы.",
"not_found": "Not Found!",
"were_sorry_whatever_you_were_looking_for_isnt_here": "We're sorry; whatever you were looking for isn't here..",
"were_sorry_whatever_you_were_looking_for_isnt_here": "Извините, но что бы вы не искали, этого тут нет..",
//Notifications
"no_notifications": "No notifications",
"1_notification": "1 notification",
"notifications": "notifications",
"mark_all_as_read": "Mark all as read",
"no_notifications": "Оповещений нет",
"1_notification": "1 оповещение",
"notifications": "оповещения",
"mark_all_as_read": "Отметить всё прочитанным",
// Post deleted
"your_post_has_been_deleted": "Your post has been deleted.",
"your_post_has_been_deleted": "Ваш пост удалён.",
// Post submit & edit
"created": "Создан",
"title": "Заголовок",
"suggest_title": "Suggest title",
"suggest_title": "Предложите название",
"url": "URL",
"short_url": "Short URL",
"body": "Тело",
"short_url": "Короткий URL",
"body": "Body",
"category": "Категория",
"inactive_": "Inactive?",
"sticky_": "Sticky?",
"submission_date": "Submission Date",
"submission_time": "Submission Time",
"inactive_": "Сделать неактивным?",
"sticky_": "С закладкой?",
"submission_date": "Дата отправки на утверждение",
"submission_time": "Время отправки на утверждение",
"date": "Дата",
"submission": "Submission",
"note_this_post_is_still_pending_so_it_has_no_submission_timestamp_yet": "Note: this post is still pending so it has no submission timestamp yet.",
"submission": "Утверждение",
"note_this_post_is_still_pending_so_it_has_no_submission_timestamp_yet": "Заметка: этот пост находится на рассмотрении, поэтому время утверждения не указано.",
"user": "Пользователь",
"status_": "Статус",
"approved": "Подтверждено",
"rejected": "Отклонено",
"approved": "Утверждён",
"rejected": "Отклонён",
"delete_post": "Удалить пост",
"thanks_your_post_is_awaiting_approval": "Thanks, your post is awaiting approval.",
"sorry_couldnt_find_a_title": "Sorry, couldn't find a title...",
"please_fill_in_an_url_first": "Please fill in an URL first!",
"thanks_your_post_is_awaiting_approval": "Спасибо, пост ожидает утверждения.",
"sorry_couldnt_find_a_title": "Извините, не смог найти название...",
"please_fill_in_an_url_first": "Вначале укажите URL!",
// Post item
"share": "Share",
"discuss": "Discuss",
"upvote_": "Upvote",
"sticky": "Sticky",
"status": "status",
"votes": "votes",
"basescore": "baseScore",
"score": "score",
"clicks": "clicks",
"views": "views",
"inactive": "inactive",
"comment": "comment",
"comments": "comments",
"point": "point",
"points": "points",
"share": "Поделится",
"discuss": "Обсудить",
"upvote_": "Проголосовать за",
"sticky": "В закладки",
"status": "статус",
"votes": "голосов",
"basescore": "базовые очки",
"score": "очки",
"clicks": "кликов",
"views": "просмотров",
"inactive": "неактивно",
"comment": "комментарий",
"comments": "комментариев",
"point": "бал",
"points": "баллов",
//User
"please_complete_your_profile_below_before_continuing": "Please complete your profile below before continuing.",
"account": "Account",
"username": "Username",
"display_name": "Display Name",
//User /client/views/users/account/user_account.html
"please_complete_your_profile_below_before_continuing": "Заполните ваш профиль перед тем, как продолжить.",
"account": "Аккаунт",
"username": "Имя пользователя",
"display_name": "Показать имя",
"email": "Email",
"bio": "Bio",
"password": "Password",
"change_password": "Change Password?",
"old_password": "Old Password",
"new_password": "New Password",
"email_notifications": "Email Notifications",
"new_posts": "New Posts",
"comments_on_my_posts": "Comments on my posts",
"replies_to_my_comments": "Replies to my comments",
"forgot_password": "Forgot password?",
"profile_updated": "Profile updated",
"please_fill_in_your_email_below_to_finish_signing_up": "Please fill in your email below to finish signing up.",
"invite": "Invite",
"uninvite": "Uninvite",
"make_admin": "Make admin",
"unadmin": "Unadmin",
"delete_user": "Delete User",
"are_you_sure_you_want_to_delete": "Are you sure you want to delete ",
"reset_password": "Reset Password",
"password_reset_link_sent": "Password reset link sent!",
"name": "Name",
"posts": "Posts",
"comments_": "Comments",
"karma": "Karma",
"is_invited": "Is Invited?",
"is_admin": "Is Admin?",
"delete": "Delete",
"member_since": "Member since",
"edit_profile": "Edit profile",
"sign_in": "Sign In",
"sign_in_": "Sign in!",
"sign_up_": "Sign up!",
"dont_have_an_account": "Don't have an account?",
"already_have_an_account": "Already have an account?",
"sign_up": "Sign Up",
"please_fill_in_all_fields": "Please fill in all fields",
"invite_": "Invite ",
"left": " left",
"invite_none_left": "Invite (none left)",
"all": "All",
"invited": "Invited",
"uninvited": "Uninvited",
"filter_by": "Filter by",
"sort_by": "Sort by",
"bio": "Обо мне",
"twitter_username": "Имя в Twitter",
"github_username": "Имя в GitHub",
"site_url": "URL сайта",
"password": "Пароль",
"change_password": "Сменить пароль?",
"old_password": "Старый пароль",
"new_password": "Новый пароль",
"email_notifications": "Email оповещение",
"new_users": "Новые пользователи",
"new_posts": "Новые посты",
"comments_on_my_posts": "Комментариев под моими постами",
"replies_to_my_comments": "Ответов на мои комментарии",
"forgot_password": "Забыли пароль?",
"profile_updated": "Профиль обновлён",
"please_fill_in_your_email_below_to_finish_signing_up": "Пожалуйста, укажите ваш email ниже для окончания регистрации.",
"invite": "Инвайт",
"uninvite": "Отменить инвайт",
"make_admin": "Сделать админом",
"unadmin": "Отметить админа",
"delete_user": "Удалить пользователя",
"are_you_sure_you_want_to_delete": "Уверены, что хотите удалить ",
"reset_password": "Сбросить пароль",
"password_reset_link_sent": "Ссылка для сброса пароля отправлена!",
"name": "Имя",
"posts": "Посты",
"comments_": "Комментарии",
"karma": "Карма",
"is_invited": "Приглашён?",
"is_admin": "Админ?",
"delete": "Удалить",
"member_since": "Является членом с",
"edit_profile": "Редактировать профиль",
"sign_in": "Войти",
"sign_in_": "Войти!",
"sign_up_": "Зарегистрироваться!",
"dont_have_an_account": "Нет аккаунта?",
"already_have_an_account": "Уже есть аккаунт?",
"sign_up": "Зарегистрироваться",
"please_fill_in_all_fields": "Заполните все поля",
"invite_": "Пригласить ",
"left": " покинул(а)",
"invite_none_left": "Пригласить (не осталось)",
"all": "Все",
"invited": "Приглашённые",
"uninvited": "Неприглашённые",
"filter_by": "Фильтровать по",
"sort_by": "Сортировать по",
//helpers
"sorry_you_do_not_have_access_to_this_page": "Sorry, you do not have access to this page",
"please_sign_in_first": "Please Sign In First.",
"sorry_you_have_to_be_an_admin_to_view_this_page": "Sorry, you have to be an admin to view this page.",
"sorry_you_dont_have_permissions_to_add_new_items": "Sorry, you don't have permissions to add new items.",
"sorry_you_cannot_edit_this_post": "Sorry, you cannot edit this post.",
"sorry_you_cannot_edit_this_comment": "Sorry, you cannot edit this comment.",
"sorry_you_do_not_have_access_to_this_page": "Извините, у вас нет доступа к этой странице",
"please_sign_in_first": "Вначале войдите.",
"sorry_you_have_to_be_an_admin_to_view_this_page": "Извините, вы должны быть админом для просмотра этой страницы.",
"sorry_you_dont_have_permissions_to_add_new_items": "Извините, у вас нет прав для добавления новых элементов.",
"sorry_you_cannot_edit_this_post": "Извините, вы не можете редактировать этот пост.",
"sorry_you_cannot_edit_this_comment": "Извините, вы не можете редактировать это.",
//Collections
"you_need_to_login_and_be_an_admin_to_add_a_new_category": "You need to login and be an admin to add a new category.",
"you_need_to_login_or_be_invited_to_post_new_comments": "You need to login or be invited to post new comments.",
"please_wait": "Please wait ",
"seconds_before_commenting_again": " seconds before commenting again",
"your_comment_is_empty": "Your comment is empty.",
"you_dont_have_permission_to_delete_this_comment": "You don't have permission to delete this comment.",
"you_need_to_login_or_be_invited_to_post_new_stories": "You need to login or be invited to post new stories.",
"please_fill_in_a_headline": "Please fill in a headline",
"this_link_has_already_been_posted": "This link has already been posted",
"sorry_you_cannot_submit_more_than": "Sorry, you cannot submit more than ",
"posts_per_day": " posts per day",
"someone_replied_to_your_comment_on": "Someone replied to your comment on",
"has_replied_to_your_comment_on": " has replied to your comment on",
"read_more": "Read more",
"a_new_comment_on_your_post": "A new comment on your post",
"you_have_a_new_comment_by": "You have a new comment by ",
"on_your_post": " on your post",
"has_created_a_new_post": " has created a new post",
"your_account_has_been_approved": "Your account has been approved.",
"welcome_to": "Welcome to ",
"start_posting": "Start posting.",
"you_need_to_login_and_be_an_admin_to_add_a_new_category": "Вам нужно войти и быть админом для создания новой категории.",
"you_need_to_login_or_be_invited_to_post_new_comments": "Вам нужно войти или быть приглашённым для комментирования.",
"please_wait": "Пожалуйста подождите ",
"seconds_before_commenting_again": " секунд перед новым комментарием",
"your_comment_is_empty": "Ваш комментарий пуст.",
"you_dont_have_permission_to_delete_this_comment": "У вас нет прав для удаления этого комментария.",
"you_need_to_login_or_be_invited_to_post_new_stories": "Вам нужно войти или быть приглашённым, чтобы публиковать новые истории.",
"please_fill_in_a_headline": "Заполните заголовок",
"this_link_has_already_been_posted": "Эта ссылка уже была опубликована",
"sorry_you_cannot_submit_more_than": "Извините, вы не можете отправлять больше, чем ",
"posts_per_day": " постов за день",
"someone_replied_to_your_comment_on": "Кто-то ответил на ваш комментарий",
"has_replied_to_your_comment_on": " ответил(а) на ваш комментарий по",
"read_more": "Подробнее",
"a_new_comment_on_your_post": "Новый комментарий по вашему посту",
"you_have_a_new_comment_by": "У вас есть новый комментарий от ",
"on_your_post": " по вашему посту",
"has_created_a_new_post": " создал новый пост",
"your_account_has_been_approved": "Ваш аккаунт утвердили.",
"welcome_to": "Добро пожаловать ",
"start_posting": "Начать пост.",
// Translation needed (found during migration to tap:i18n)
"please_fill_in_a_title": "Please fill in a title",
"seconds_before_posting_again": " seconds before posting again",
"upvoted": "Upvoted",
"posted_date": "Posted Date",
"posted_time": "Posted Time",
"posted_date": "Posted Date",
"posted_time": "Posted Time",
"profile": "Profile",
"sign_out": "Sign Out",
"invitedcount": "InvitedCount",
"invites": "Invites",
"invited": "Invited?",
"admin": "Admin",
"actions": "Actions",
"invites_left": "invites left",
"id": "ID",
"name": "Name:",
"bio": "Bio:",
"please_fill_in_a_title": "Заполните заголовок",
"seconds_before_posting_again": " секунд перед новым постом",
"upvoted": "За",
"posted_date": "Дата поста",
"posted_time": "Время поста",
"posted_date": "Дата поста",
"posted_time": "Время поста",
"profile": "Профиль",
"sign_out": "Выйти",
"you_ve_been_signed_out": "Вы вышли. Возвращайтесь снова!",
"invitedcount": "Подсчёт инвайтов",
"invites": "Инвайты",
"invited": "Приглашены?",
"admin": "Админ",
"actions": "Действия",
"invites_left": "осталось инвайтов",
"id": "ИД",
"name": "Имя:",
"bio": "Обо мне:",
"github": "GitHub",
"site": "Site",
"upvoted_posts": "Upvoted Posts",
"downvoted_posts": "Downvoted Posts",
"mark_as_read": "Mark as read",
"site": "Сайт",
"upvoted_posts": "Постов За",
"downvoted_posts": "Постов Против",
"mark_as_read": "Отметить прочитанным",
//Common
"pending": "В ожидании",
"loading": "Загрузка...",
"pending": "Ожидает",
"loading": "Загружается...",
"submit": "Отправить",
"you_must_be_logged_in": "You must be logged in.",
"are_you_sure": "Вы уверены?",
"please_log_in_first": "Please log in first",
"sign_in_sign_up_with_twitter": "Sign In/Sign Up with Twitter",
"load_more": "Загрузить еще"
"you_must_be_logged_in": "Вы должны залогиниться.",
"are_you_sure": "Уверены?",
"please_log_in_first": "Войдите вначале",
"sign_in_sign_up_with_twitter": "Войти/зарегистрироваться с помощью Twitter",
"load_more": "Загрузить ещё"
}

View file

@ -5,9 +5,9 @@
//Fields
AccountsTemplates.addField({
_id: "username",
type: "text",
displayName: "username",
_id: 'username',
type: 'text',
displayName: 'username',
required: true,
minLength: 3,
errStr: 'error.minChar'
@ -35,22 +35,22 @@ AccountsTemplates.addField({
/*
AccountsTemplates.addField({
_id: "username_and_email",
type: "text",
displayName: "Name or Email",
placeholder: "name or email",
_id: 'username_and_email',
type: 'text',
displayName: 'Name or Email',
placeholder: 'name or email',
});
*/
//Routes
AccountsTemplates.configureRoute("signIn");
AccountsTemplates.configureRoute("signUp");
AccountsTemplates.configureRoute("forgotPwd");
AccountsTemplates.configureRoute("resetPwd");
//AccountsTemplates.configureRoute("changePwd");
//AccountsTemplates.configureRoute("enrollAccount");
//AccountsTemplates.configureRoute("verifyEmail");
AccountsTemplates.configureRoute('signIn');
AccountsTemplates.configureRoute('signUp');
AccountsTemplates.configureRoute('forgotPwd');
AccountsTemplates.configureRoute('resetPwd');
//AccountsTemplates.configureRoute('changePwd');
//AccountsTemplates.configureRoute('enrollAccount');
//AccountsTemplates.configureRoute('verifyEmail');
// Options
@ -64,14 +64,11 @@ AccountsTemplates.configure({
positiveFeedback: false,
negativeValidation: true,
positiveValidation: true
/*
sendVerificationEmail: true,
continuousValidation: false,
showLabels: true,
forbidClientAccountCreation: false,
formValidationFeedback: true,
homeRoutePath: "/",
showAddRemoveServices: false,
showPlaceholders: true,
*/
});
});
// hack to get signOut route not considered among previous paths
if (Meteor.isClient) {
Meteor.startup(function(){
AccountsTemplates.knownRoutes.push('/sign-out');
});
}

View file

@ -1,19 +1,19 @@
// returns how much "power" a user's votes have
var getVotePower = function(user){
var getVotePower = function (user) {
// return isAdmin(user) ? 5 : 1;
return 1; // for now, leave everybody at 1 including admins; 5 is too unbalanced
};
var modifyKarma = function(userId, karma){
var modifyKarma = function (userId, karma) {
Meteor.users.update({_id: userId}, {$inc: {karma: karma}});
};
var hasUpvotedItem= function(item, user){
var hasUpvotedItem = function (item, user) {
return item.upvoters && item.upvoters.indexOf(user._id) != -1;
};
var hasDownvotedItem= function(item, user){
var hasDownvotedItem = function (item, user) {
return item.downvoters && item.downvoters.indexOf(user._id) != -1;
};
@ -35,7 +35,7 @@
});
};
var upvoteItem = function(collection, item) {
var upvoteItem = function (collection, item) {
var user = Meteor.user(),
votePower = getVotePower(user),
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
@ -49,7 +49,7 @@
cancelDownvote(collection, item, user);
// Votes & Score
var result = collection.update({_id: item && item._id, upvoters: {$not: {$in: [user._id]}}},{
var result = collection.update({_id: item && item._id, upvoters: { $ne: user._id }},{
$addToSet: {upvoters: user._id},
$inc: {upvotes: 1, baseScore: votePower},
$set: {inactive: false}
@ -69,13 +69,13 @@
updateScore({collection: collection, item: item, forceUpdate: true});
// if the item is being upvoted by its own author, don't give karma
if (item.userId != user._id){
if (item.userId != user._id) {
modifyKarma(item.userId, votePower);
// 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)){
_.each(item.upvoters, function(upvoterId){
if (getSetting('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);
modifyKarma(upvoterId, 0.1);
@ -87,7 +87,7 @@
return true;
};
var downvoteItem = function(collection, item) {
var downvoteItem = function (collection, item) {
var user = Meteor.user(),
votePower = getVotePower(user),
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
@ -100,7 +100,7 @@
cancelUpvote(collection, item, user);
// Votes & Score
var result = collection.update({_id: item && item._id, downvoters: {$not: {$in: [user._id]}}},{
var result = collection.update({_id: item && item._id, downvoters: { $ne: user._id }},{
$addToSet: {downvoters: user._id},
$inc: {downvotes: 1, baseScore: -votePower},
$set: {inactive: false}
@ -127,17 +127,17 @@
return true;
};
var cancelUpvote = function(collection, item) {
var user = Meteor.user();
var cancelUpvote = function (collection, item) {
var user = Meteor.user(),
votePower = getVotePower(user),
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
// if user isn't among the upvoters, abort
if(!hasUpvotedItem(item, user))
if (!hasUpvotedItem(item, user))
return false;
// Votes & Score
var result = collection.update({_id: item && item._id, upvoters: { $in: [user._id]}},{
var result = collection.update({_id: item && item._id, upvoters: user._id},{
$pull: {upvoters: user._id},
$inc: {upvotes: -1, baseScore: -votePower},
$set: {inactive: false}
@ -159,17 +159,17 @@
return true;
};
var cancelDownvote = function(collection, item) {
var cancelDownvote = function (collection, item) {
var user = Meteor.user(),
votePower = getVotePower(user),
collectionName = collection._name.slice(0,1).toUpperCase()+collection._name.slice(1);
// if user isn't among the downvoters, abort
if(!hasDownvotedItem(item, user))
if (!hasDownvotedItem(item, user))
return false;
// Votes & Score
var result = collection.update({_id: item && item._id, downvoters: {$in: [user._id]}},{
var result = collection.update({_id: item && item._id, downvoters: user._id},{
$pull: {downvoters: user._id},
$inc: {downvotes: 1, baseScore: votePower},
$set: {inactive: false}
@ -192,35 +192,35 @@
};
// note: doesn't actually seem very useful to enable admins to vote for other users. Remove this?
var getUser = function(user){
var getUser = function (user) {
// only let admins specify different users for voting
// if no user is specified, use current user by default
return (isAdmin(Meteor.user()) && typeof user !== 'undefined') ? user : Meteor.user();
};
Meteor.methods({
upvotePost: function(post, user){
upvotePost: function (post, user) {
return upvoteItem.call(this, Posts, post);
},
downvotePost: function(post, user){
downvotePost: function (post, user) {
return downvoteItem.call(this, Posts, post);
},
cancelUpvotePost: function(post, user){
cancelUpvotePost: function (post, user) {
return cancelUpvote.call(this, Posts, post);
},
cancelDownvotePost: function(post, user){
cancelDownvotePost: function (post, user) {
return cancelDownvote.call(this, Posts, post);
},
upvoteComment: function(comment, user){
upvoteComment: function (comment, user) {
return upvoteItem.call(this, Comments, comment);
},
downvoteComment: function(comment, user){
downvoteComment: function (comment, user) {
return downvoteItem.call(this, Comments, comment);
},
cancelUpvoteComment: function(comment, user){
cancelUpvoteComment: function (comment, user) {
return cancelUpvote.call(this, Comments, comment);
},
cancelDownvoteComment: function(comment, user){
cancelDownvoteComment: function (comment, user) {
return cancelDownvote.call(this, Comments, comment);
}
});