mirror of
https://github.com/vale981/Vulcan
synced 2025-03-08 19:11:38 -05:00
Merge branch 'bitly'
This commit is contained in:
commit
7a92f405f8
10 changed files with 52 additions and 6 deletions
|
@ -1420,13 +1420,13 @@ form .control-group, .accounts-dialog .control-group {
|
||||||
margin-left: 150px;
|
margin-left: 150px;
|
||||||
position: relative; }
|
position: relative; }
|
||||||
/* line 19, ../sass/modules/_forms.scss */
|
/* line 19, ../sass/modules/_forms.scss */
|
||||||
form .control-group .controls .get-title-link, .accounts-dialog .control-group .controls .get-title-link {
|
form .control-group .controls .inline-link, .accounts-dialog .control-group .controls .inline-link {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
display: block;
|
||||||
top: 2px;
|
top: 2px;
|
||||||
right: 8px; }
|
right: 8px; }
|
||||||
/* line 24, ../sass/modules/_forms.scss */
|
/* line 24, ../sass/modules/_forms.scss */
|
||||||
form .control-group .controls .get-title-link.loading, .accounts-dialog .control-group .controls .get-title-link.loading {
|
form .control-group .controls .inline-link.loading, .accounts-dialog .control-group .controls .inline-link.loading {
|
||||||
background: url(/img/loading.gif) center center no-repeat;
|
background: url(/img/loading.gif) center center no-repeat;
|
||||||
height: 22px;
|
height: 22px;
|
||||||
width: 18px;
|
width: 18px;
|
||||||
|
|
|
@ -25,6 +25,7 @@ Setting = FormModel.extend({
|
||||||
clickyId:'',
|
clickyId:'',
|
||||||
goSquaredId: '',
|
goSquaredId: '',
|
||||||
embedlyId: '',
|
embedlyId: '',
|
||||||
|
bitlyToken: '',
|
||||||
footerCode: '',
|
footerCode: '',
|
||||||
extraCode: '',
|
extraCode: '',
|
||||||
notes: ''
|
notes: ''
|
||||||
|
@ -40,6 +41,7 @@ Setting = FormModel.extend({
|
||||||
this.overwriteTitle('mixpanelId', '<a href="http://mixpanel.com/">Mixpanel</a> ID');
|
this.overwriteTitle('mixpanelId', '<a href="http://mixpanel.com/">Mixpanel</a> ID');
|
||||||
this.overwriteTitle('clickyId', '<a href="http://getclicky.com/">Clicky</a> ID');
|
this.overwriteTitle('clickyId', '<a href="http://getclicky.com/">Clicky</a> ID');
|
||||||
this.overwriteTitle('goSquaredId', '<a href="http://gosquared.com/">GoSquared</a> ID');
|
this.overwriteTitle('goSquaredId', '<a href="http://gosquared.com/">GoSquared</a> ID');
|
||||||
|
this.overwriteTitle('bitlyToken', '<a href="https://bitly.com/a/oauth_apps">Bitly</a> Token');
|
||||||
this.overwriteTitle('logoUrl', 'Logo URL');
|
this.overwriteTitle('logoUrl', 'Logo URL');
|
||||||
this.overwriteType('footerCode', 'textarea');
|
this.overwriteType('footerCode', 'textarea');
|
||||||
this.overwriteType('extraCode', 'textarea');
|
this.overwriteType('extraCode', 'textarea');
|
||||||
|
|
|
@ -16,7 +16,7 @@ form, .accounts-dialog{
|
||||||
.controls{
|
.controls{
|
||||||
margin-left:150px;
|
margin-left:150px;
|
||||||
position:relative;
|
position:relative;
|
||||||
.get-title-link{
|
.inline-link{
|
||||||
position:absolute;
|
position:absolute;
|
||||||
display:block;
|
display:block;
|
||||||
top:2px;
|
top:2px;
|
||||||
|
|
|
@ -14,6 +14,12 @@
|
||||||
<label class="control-label post-form-url">URL</label>
|
<label class="control-label post-form-url">URL</label>
|
||||||
<div class="controls"><input id="url" type="text" value="{{url}}" /></div>
|
<div class="controls"><input id="url" type="text" value="{{url}}" /></div>
|
||||||
</div>
|
</div>
|
||||||
|
{{#if shorten}}
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label post-form-url">Short URL</label>
|
||||||
|
<div class="controls"><input id="short-url" type="text" value="{{shortUrl}}" /></div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label post-form-body">Body</label>
|
<label class="control-label post-form-body">Body</label>
|
||||||
<div class="controls" id="editor"><textarea id="body" value="" class="input-xlarge">{{body}}</textarea></div>
|
<div class="controls" id="editor"><textarea id="body" value="" class="input-xlarge">{{body}}</textarea></div>
|
||||||
|
|
|
@ -52,6 +52,9 @@ Template.post_edit.helpers({
|
||||||
hasStatusRejected: function(){
|
hasStatusRejected: function(){
|
||||||
return this.status == STATUS_REJECTED ? 'checked' : '';
|
return this.status == STATUS_REJECTED ? 'checked' : '';
|
||||||
},
|
},
|
||||||
|
shorten: function(){
|
||||||
|
return !!getSetting('bitlyToken');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Template.post_edit.rendered = function(){
|
Template.post_edit.rendered = function(){
|
||||||
|
@ -78,6 +81,7 @@ Template.post_edit.events = {
|
||||||
var post = Posts.findOne(selectedPostId);
|
var post = Posts.findOne(selectedPostId);
|
||||||
var categories = [];
|
var categories = [];
|
||||||
var url = $('#url').val();
|
var url = $('#url').val();
|
||||||
|
var shortUrl = $('#short-url').val();
|
||||||
var status = parseInt($('input[name=status]:checked').val());
|
var status = parseInt($('input[name=status]:checked').val());
|
||||||
|
|
||||||
$('input[name=category]:checked').each(function() {
|
$('input[name=category]:checked').each(function() {
|
||||||
|
@ -88,6 +92,7 @@ Template.post_edit.events = {
|
||||||
|
|
||||||
var properties = {
|
var properties = {
|
||||||
headline: $('#title').val(),
|
headline: $('#title').val(),
|
||||||
|
shortUrl: shortUrl,
|
||||||
body: instance.editor.exportFile(),
|
body: instance.editor.exportFile(),
|
||||||
categories: categories,
|
categories: categories,
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Title</label>
|
<label class="control-label">Title</label>
|
||||||
<div class="controls"><input id="title" type="text" value="" /><a href="#" class="get-title-link">Suggest title</a></div>
|
<div class="controls"><input id="title" type="text" value="" /><a href="#" class="get-title-link inline-link">Suggest title</a></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Message</label>
|
<label class="control-label">Message</label>
|
||||||
|
|
|
@ -36,6 +36,7 @@ Template.post_submit.events = {
|
||||||
|
|
||||||
var title= $('#title').val();
|
var title= $('#title').val();
|
||||||
var url = $('#url').val();
|
var url = $('#url').val();
|
||||||
|
var shortUrl = $('#short-url').val();
|
||||||
var body = instance.editor.exportFile();
|
var body = instance.editor.exportFile();
|
||||||
var categories=[];
|
var categories=[];
|
||||||
var sticky=!!$('#sticky').attr('checked');
|
var sticky=!!$('#sticky').attr('checked');
|
||||||
|
@ -50,6 +51,7 @@ Template.post_submit.events = {
|
||||||
var properties = {
|
var properties = {
|
||||||
headline: title
|
headline: title
|
||||||
, body: body
|
, body: body
|
||||||
|
, shortUrl: shortUrl
|
||||||
, categories: categories
|
, categories: categories
|
||||||
, sticky: sticky
|
, sticky: sticky
|
||||||
, submitted: submitted
|
, submitted: submitted
|
||||||
|
@ -95,4 +97,5 @@ Template.post_submit.events = {
|
||||||
$(".get-title-link").removeClass("loading");
|
$(".get-title-link").removeClass("loading");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,7 +16,6 @@ Template.posts_list.helpers({
|
||||||
return this.fetch();
|
return this.fetch();
|
||||||
},
|
},
|
||||||
postsReady: function() {
|
postsReady: function() {
|
||||||
console.log('checking postsReady', this.ready(), this);
|
|
||||||
return this.ready();
|
return this.ready();
|
||||||
},
|
},
|
||||||
allPostsLoaded: function(){
|
allPostsLoaded: function(){
|
||||||
|
|
|
@ -44,6 +44,23 @@ Meteor.methods({
|
||||||
throw new Meteor.Error(605, 'Sorry, you cannot submit more than '+maxPostsPer24Hours+' posts per day');
|
throw new Meteor.Error(605, 'Sorry, you cannot submit more than '+maxPostsPer24Hours+' posts per day');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// shorten URL
|
||||||
|
if(!this.isSimulation && (token=getSetting('bitlyToken'))){
|
||||||
|
var shortenResponse = Meteor.http.get(
|
||||||
|
"https://api-ssl.bitly.com/v3/shorten?",
|
||||||
|
{
|
||||||
|
timeout: 5000,
|
||||||
|
params:{
|
||||||
|
"format": "json",
|
||||||
|
"access_token": token,
|
||||||
|
"longUrl": post.url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
if(shortenResponse.statusCode == 200)
|
||||||
|
post.shortUrl = shortenResponse.data.data.url
|
||||||
|
}
|
||||||
|
|
||||||
post = _.extend(post, {
|
post = _.extend(post, {
|
||||||
headline: headline,
|
headline: headline,
|
||||||
body: body,
|
body: body,
|
||||||
|
|
|
@ -78,6 +78,20 @@ slugify = function(text) {
|
||||||
text = text.toLowerCase();
|
text = text.toLowerCase();
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
getShortUrl = function(url, func){
|
||||||
|
$.getJSON(
|
||||||
|
"https://api-ssl.bitly.com/v3/shorten?callback=?",
|
||||||
|
{
|
||||||
|
"format": "json",
|
||||||
|
"access_token": getSetting('bitlyToken'),
|
||||||
|
"longUrl": url
|
||||||
|
},
|
||||||
|
function(response){
|
||||||
|
func(response.data.url);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------- String Helper Functions ----------------------------------- //
|
// ---------------------------------- String Helper Functions ----------------------------------- //
|
||||||
cleanUp = function(s){
|
cleanUp = function(s){
|
||||||
return stripHTML(s);
|
return stripHTML(s);
|
||||||
|
|
Loading…
Add table
Reference in a new issue