mirror of
https://github.com/vale981/Vulcan
synced 2025-03-06 01:51:40 -05:00
renaming "rss" to "feed"
This commit is contained in:
parent
b7ba4b3bc0
commit
a379f605cf
22 changed files with 72 additions and 71 deletions
|
@ -75,6 +75,6 @@ telescope-kadira
|
|||
telescope-notifications
|
||||
telescope-singleday
|
||||
telescope-invites
|
||||
telescope-post-by-rss
|
||||
telescope-post-by-feed
|
||||
|
||||
# Custom Packages
|
||||
|
|
4
packages/telescope-post-by-feed/i18n/en.i18n.json
Normal file
4
packages/telescope-post-by-feed/i18n/en.i18n.json
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"feed_already_exists": "A feed with the same URL already exists.",
|
||||
"you_need_to_login_and_be_an_admin_to_add_a_new_feed": "You need to log in and be an admin to add a new feed."
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<template name="feedItem">
|
||||
<li>
|
||||
<span>Url: {{url}}</span>
|
||||
<a class="delete-feed" href="#">Delete</a>
|
||||
</li>
|
||||
</template>
|
|
@ -0,0 +1,10 @@
|
|||
Meteor.startup(function () {
|
||||
Template[getTemplate('feedItem')].events({
|
||||
'click .delete-feed': function(e, instance){
|
||||
e.preventDefault();
|
||||
|
||||
if (confirm(i18n.t('are_you_sure')))
|
||||
Feeds.remove(instance.data._id);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,9 +1,9 @@
|
|||
<template name="rssUrls">
|
||||
<div class="grid-small grid-module dialog admin">
|
||||
<h2>RSS Urls</h2>
|
||||
<h2>Feeds</h2>
|
||||
|
||||
<form class="form-block">
|
||||
<h3>Add new RSS Url</h3>
|
||||
<h3>Add New Feed</h3>
|
||||
<div class="control-group">
|
||||
<label>Url</label>
|
||||
<div class="controls"><input id="url" type="text" value="" /></div>
|
||||
|
@ -13,8 +13,8 @@
|
|||
</div>
|
||||
</form>
|
||||
<ul>
|
||||
{{#each rssUrls}}
|
||||
{{> UI.dynamic template=rssUrlItem}}
|
||||
{{#each feeds}}
|
||||
{{> UI.dynamic template=feedItem}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
|
@ -1,20 +1,20 @@
|
|||
Meteor.startup(function () {
|
||||
Template[getTemplate('rssUrls')].helpers({
|
||||
rssUrls: function(){
|
||||
return RssUrls.find({}, {sort: {url: 1}});
|
||||
Template[getTemplate('feeds')].helpers({
|
||||
feeds: function(){
|
||||
return Feeds.find({}, {sort: {url: 1}});
|
||||
},
|
||||
rssUrlItem: function () {
|
||||
return getTemplate('rssUrlItem');
|
||||
feedItem: function () {
|
||||
return getTemplate('feedItem');
|
||||
}
|
||||
});
|
||||
|
||||
Template[getTemplate('rssUrls')].events({
|
||||
Template[getTemplate('feeds')].events({
|
||||
'click input[type=submit]': function(e){
|
||||
e.preventDefault();
|
||||
|
||||
var url = $('#url').val();
|
||||
|
||||
Meteor.call('insertRssUrl', {url: url}, function(error, result) {
|
||||
Meteor.call('insertFeed', {url: url}, function(error, result) {
|
||||
if(error){
|
||||
console.log(error);
|
||||
flashMessage(error.reason, "error");
|
35
packages/telescope-post-by-feed/lib/feeds.js
Normal file
35
packages/telescope-post-by-feed/lib/feeds.js
Normal file
|
@ -0,0 +1,35 @@
|
|||
// feedSchema schema
|
||||
feedSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
optional: true
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Url
|
||||
}
|
||||
});
|
||||
|
||||
Feeds = new Meteor.Collection("feeds", {
|
||||
schema: feedSchema
|
||||
});
|
||||
|
||||
Meteor.startup(function () {
|
||||
Feeds.allow({
|
||||
remove: isAdminById
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
insertFeed: function(feedUrl){
|
||||
check(feedUrl, feedSchema);
|
||||
|
||||
if (Feeds.findOne({url: feedSchema.url}))
|
||||
throw new Meteor.Error('already-exists', i18n.t('feed_already_exists'));
|
||||
|
||||
if (!Meteor.user() || !isAdmin(Meteor.user()))
|
||||
throw new Meteor.Error('login-required', i18n.t('you_need_to_login_and_be_an_admin_to_add_a_new_feed'));
|
||||
|
||||
return Feeds.insert(feedUrl);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,9 +1,9 @@
|
|||
SyncedCron.add({
|
||||
name: 'Post by RSS url',
|
||||
name: 'Post by RSS feed',
|
||||
schedule: function(parser) {
|
||||
return parser.text('every 10 mins');
|
||||
},
|
||||
job: function() {
|
||||
fetchUrls();
|
||||
fetchFeeds();
|
||||
}
|
||||
});
|
|
@ -78,10 +78,10 @@ var handleFeed = function(error, feed) {
|
|||
});
|
||||
};
|
||||
|
||||
fetchUrls = function() {
|
||||
fetchFeeds = function() {
|
||||
var content;
|
||||
|
||||
RssUrls.find().forEach(function(rssUrl) {
|
||||
Feeds.find().forEach(function(rssUrl) {
|
||||
try {
|
||||
content = HTTP.get(rssUrl.url).content;
|
||||
} catch (e) {
|
|
@ -1,7 +1,7 @@
|
|||
Package.describe({
|
||||
summary: 'Auto post via RSS to Telescope',
|
||||
version: '0.0.1',
|
||||
name: 'telescope-post-by-rss'
|
||||
name: 'telescope-post-by-feed'
|
||||
});
|
||||
|
||||
Npm.depends({
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"rss_url_is_already_exists": "Url is already exists."
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
<template name="rssUrlItem">
|
||||
<li>
|
||||
<span>Url: {{url}}</span>
|
||||
<a class="delete-url" href="#">Delete</a>
|
||||
</li>
|
||||
</template>
|
|
@ -1,10 +0,0 @@
|
|||
Meteor.startup(function () {
|
||||
Template[getTemplate('rssUrlItem')].events({
|
||||
'click .delete-url': function(e, instance){
|
||||
e.preventDefault();
|
||||
|
||||
if (confirm(i18n.t('are_you_sure')))
|
||||
RssUrls.remove(instance.data._id);
|
||||
}
|
||||
});
|
||||
});
|
|
@ -1,35 +0,0 @@
|
|||
// rssUrl schema
|
||||
rssUrlSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
optional: true
|
||||
},
|
||||
url: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Url
|
||||
},
|
||||
});
|
||||
|
||||
RssUrls = new Meteor.Collection("rss_urls", {
|
||||
schema: rssUrlSchema
|
||||
});
|
||||
|
||||
Meteor.startup(function () {
|
||||
RssUrls.allow({
|
||||
remove: isAdminById
|
||||
});
|
||||
|
||||
Meteor.methods({
|
||||
insertRssUrl: function(rssUrl){
|
||||
check(rssUrl, rssUrlSchema);
|
||||
|
||||
if (RssUrls.findOne({url: rssUrl.url}))
|
||||
throw new Meteor.Error('already-exists', i18n.t('rss_url_is_already_exists'));
|
||||
|
||||
if (!Meteor.user() || !isAdmin(Meteor.user()))
|
||||
throw new Meteor.Error('login-required', i18n.t('you_need_to_login_and_be_an_admin_to_add_a_new_rss_url'));
|
||||
|
||||
return RssUrls.insert(rssUrl);
|
||||
}
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue