test if either http:// or https:// is missing from URLs

This commit is contained in:
Sacha Greif 2012-12-31 18:18:46 +01:00
parent a111f71384
commit 05fcbaf1bd
5 changed files with 18 additions and 14 deletions

View file

@ -1,5 +1,9 @@
Session.set('initialLoad', true);
l=function(s){
console.log(s);
}
// HELPERS
getSetting = function(setting){
var settings=Settings.find().fetch()[0];

View file

@ -3,18 +3,18 @@
{{#constant}}{{#with post}}
<form class="grid-block form-horizontal">
<div class="control-group">
<label class="control-label">Title</label>
<label class="control-label post-form-headline">Title</label>
<div class="controls"><input id="title" type="text" value="{{headline}}" /></div>
</div>
<div class="control-group">
<label class="control-label">URL</label>
<label class="control-label post-form-url">URL</label>
<div class="controls"><input id="url" type="text" value="{{url}}" /></div>
</div>
<div class="control-group">
<label class="control-label">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>
<div class="control-group">
<div class="control-group post-form-category">
<label class="control-label">Category</label>
<div class="controls">
{{#each categories}}
@ -25,22 +25,22 @@
</div>
</div>
{{#if isAdmin}}
<div class="control-group">
<div class="control-group post-form-sticky">
<label class="control-label">Sticky?</label>
<div class="controls">
<input type="checkbox" name="sticky" id="sticky" {{#if sticky}}checked{{/if}} />
</div>
</div>
<div class="control-group">
<label class="control-label">Date</label>
<label class="control-label post-form-date">Date</label>
<div class="controls"><input id="submitted_date" type="text" value="{{submittedDate}}" /></div>
<input id="submitted_hidden" type="hidden" value="{{submitted}}" />
</div>
<div class="control-group">
<label class="control-label">Time</label>
<label class="control-label post-form-time">Time</label>
<div class="controls"><input id="submitted_time" type="text" value="{{submittedTime}}" /></div>
</div>
<div class="control-group">
<div class="control-group post-form-user">
<label class="control-label">User</label>
<div class="controls">
<select id="postUser">
@ -50,7 +50,7 @@
</select>
</div>
</div>
<div class="control-group">
<div class="control-group post-form-status">
<label class="control-label">Status</label>
<div class="controls">
<label class="radio inline">

View file

@ -72,7 +72,7 @@ Template.post_edit.events = {
var properties = {
headline: $('#title').val(),
url: url.substring(0, 7) == "http://" ? url : "http://"+url,
url: (url.substring(0, 7) == "http://" || url.substring(0, 8) == "https://") ? url : "http://"+url,
body: instance.editor.exportFile(),
categories: categories,
};

View file

@ -40,7 +40,7 @@ Template.post_submit.events = {
var title= $('#title').val();
var url = $('#url').val();
var cleanUrl = url.substring(0, 7) == "http://" ? url : "http://"+url;
var cleanUrl = (url.substring(0, 7) == "http://" || url.substring(0, 8) == "https://") ? url : "http://"+url;
var body = instance.editor.exportFile();
var categories=[];
var sticky=!!$('#sticky').attr('checked');

View file

@ -34,7 +34,7 @@ var updateScore = function (collection, id, forceUpdate) {
// only update database if difference is larger than x to avoid unnecessary updates
if (forceUpdate || scoreDiff > x){
console.log('updating: '+object.headline)
// console.log('updating: '+object.headline)
collection.update(id, {$set: {score: newScore}});
return 1;
}else if(ageInHours > n*24){
@ -59,8 +59,8 @@ Meteor.startup(function () {
Comments.find({'inactive': {$ne : true}}).forEach(function (comment) {
updatedComments += updateScore(Comments, comment._id);
});
console.log("Updated "+updatedPosts+"/"+Posts.find().count()+" Posts")
console.log("Updated "+updatedComments+"/"+Comments.find().count()+" Comments")
// console.log("Updated "+updatedPosts+"/"+Posts.find().count()+" Posts")
// console.log("Updated "+updatedComments+"/"+Comments.find().count()+" Comments")
}, scoreInterval * 1000);
// inactive items get updated every hour