Skip to content
Browse files

Updated for new tutorial on using Amazon S3 for images

  • Loading branch information...
1 parent 1b30f2c commit 387c2ccf710c47d3b4b80ec27ccb5c11a7f70b5c @mikevalstar committed Oct 16, 2012
View
2 app.js
@@ -13,7 +13,7 @@ var app = express();
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
- app.use(express.bodyParser());
+ app.use(express.bodyParser({ keepExtensions: true, uploadDir: __dirname + "/tmp" }));
app.use(express.methodOverride());
app.use(express.cookieParser());
app.use(express.compress());
View
6 htdocs/css/bootstrap/bootstrap.less
@@ -39,8 +39,8 @@
@import "alerts.less"; // Note: alerts share common CSS with buttons and thus have styles in buttons.less
// Components: Nav
-//@import "navs.less";
-//@import "navbar.less";
+@import "navs.less";
+@import "navbar.less";
//@import "breadcrumbs.less";
@import "pagination.less";
@import "pager.less";
@@ -51,7 +51,7 @@
//@import "popovers.less";
// Components: Misc
-//@import "thumbnails.less";
+@import "thumbnails.less";
@import "labels-badges.less";
//@import "progress-bars.less";
//@import "accordion.less";
View
15 htdocs/css/style.less
@@ -206,6 +206,10 @@ body{
}
}
+#disqus_identity, #disqus_permalink {
+ display: none;
+}
+
// Other
a.twitter{ background: url('../img/social/16px/twitter-2.png') no-repeat bottom left; padding-left: 19px; }
a.reddit{ background: url('../img/social/16px/reddit.png') no-repeat bottom left; padding-left: 19px; }
@@ -216,6 +220,17 @@ a.linkedin{ background: url('../img/social/16px/linkedin.png') no-repeat bottom
a.stackoverflow{ background: url('../img/social/16px/stackoverflow.png') no-repeat bottom left; padding-left: 19px; }
a.flickr{ background: url('../img/social/16px/flickr.png') no-repeat bottom left; padding-left: 19px; }
+// Admin
+.dropzone{
+ border: 2px dashed @colorGray;
+ color: @colorGray;
+ font-weight: bold;
+ padding: 0.5em 2em;
+ min-width: 20em;
+ text-align: center;
+ background: lighten(@colorGray, 20%);
+}
+
/* Retina Displays */
@media only screen and (-webkit-min-device-pixel-ratio: 2) {
background-image: url("../img/noisy_grid_@2X.png");
View
142 htdocs/js/admin.js
@@ -0,0 +1,142 @@
+/*
+ Welcome to my Javascript
+
+ Please vist mikevalstar.com for an explination
+ about how some of the below is done.
+*/
+
+jQuery.event.fixHooks.drop = { props: [ "dataTransfer" ] };
+
+if(typeof MV == 'undefined') var MV = {};
+
+MV.admin = {};
+
+/*******************************
+Image List builder for display
+*******************************/
+MV.admin.imageList = function(list, selectfunc){ this._ele = list; this.init(selectfunc); };
+MV.admin.imageList.prototype = {
+ _ele: null,
+ _onselect: null,
+
+ init: function(selectfunc){
+ // display the image listing in the element
+ var imgListObj = this;
+ this._onselect = selectfunc || function(e){e.preventDefault();};
+
+ MV.admin.data.images.list(function(data){ imgListObj._fillContainer.call(imgListObj, data); });
+
+ // Define drop zone for uploading
+ if($('.dropimglead').length > 0){
+ $('.dropimglead').on( 'dragenter', function(e) {
+ e.preventDefault();
+ $(this).html('Drop Here');
+ }).on( 'dragleave', function(e) {
+ e.preventDefault();
+ $(this).html('Drag a file here to upload');
+ }).on( 'drop', function(e){
+ e.preventDefault();
+
+ $(this).html('Uploading file!!!');
+
+ // Send the image to the server
+ var self = this;
+ MV.admin.data.images.upload('lead', e.dataTransfer.files[0], function(results){
+ $(self).html('File Uploaded.').hide().fadeIn(2000);
+ var reset = function(){ $(self).html('Drag a file here to upload'); };
+ setTimeout(reset, 3000);
+ imgListObj.refresh();
+ });
+ });
+ }
+ },
+ refresh:function(){
+ var self = this;
+ MV.admin.data.images.list(function(data){ self._fillContainer.call(self, data); });
+ },
+ _fillContainer: function(data){
+ this._ele.html(''); // clear the gallary
+ if(data.images){
+ var list = $('<ul></ul>').addClass('thumbnails');
+ this._ele.append(list);
+ $(data.images).each(function(index, item){
+ list.append('<li class="span2"><a href="#" class="thumbnail" data-id="' + item.imageShort + '"><img class="retina" src="' + item.image + '" alt="' + item.imageShort + '" style="height: 150px; width: 150px;" /></a></li>');
+ });
+
+ this._ele.find('.thumbnail').click(this._onselect);
+
+ MV.imageReplace();
+ }
+ }
+};
+
+/*******************************
+Data Getters and Setters
+*******************************/
+MV.admin.data = {
+ images: {
+ list: function(callback){
+ $.get('/Admin/AJAX/Images', callback);
+ },
+ upload: function(type, file, callback){
+ // using:
+ // http://hacks.mozilla.org/2011/01/how-to-develop-a-html5-image-uploader/
+ // http://hacks.mozilla.org/2011/03/the-shortest-image-uploader-ever/
+
+ if (!file || !file.type.match(/image.*/)) return; // TODO: present error if non-image
+
+ // send form data to image post url
+ var fd = new FormData();
+ fd.append("image", file);
+ fd.append("type", type);
+ $.ajax({
+ url: '/Admin/AJAX/Image',
+ data: fd,
+ processData: false,
+ contentType: false,
+ type: 'POST'
+ }).done(callback);
+ }
+ }
+};
+
+
+$(function(){
+ if($('#imageListFull').length == 1){
+ var bigList = new MV.admin.imageList($('#imageListFull'));
+ bigList.refresh();
+ }
+
+ $('.imageSelector').click(function(e){
+ e.preventDefault();
+ var self = this;
+ var selectList = new MV.admin.imageList($( $(this).attr('data-port') ), function(e){
+ e.preventDefault();
+ $($(self).attr('data-fill')).val($(this).attr('data-id')); // set the value of the textbox
+ $($(self).attr('data-port')).html(''); // hide the images
+ });
+ });
+
+ // convert textarea tabs to the tab character
+ $("textarea").keydown(function(e) {
+ if(e.keyCode === 9) { // tab was pressed
+ // prevent the focus lose
+ e.preventDefault();
+
+ // get caret position/selection
+ var start = this.selectionStart;
+ var end = this.selectionEnd;
+
+ var $this = $(this);
+ var value = $this.val();
+
+ // set textarea value to: text before caret + tab + text after caret
+ $this.val(value.substring(0, start)
+ + "\t"
+ + value.substring(end));
+
+ // put caret at right position again (add one for the tab)
+ this.selectionStart = this.selectionEnd = start + 1;
+ }
+ });
+});
View
1 htdocs/js/jquery.tweet.js
@@ -1,5 +1,6 @@
// jquery.tweet.js - See http://tweet.seaofclouds.com/ or https://github.com/seaofclouds/tweet for more info
// Copyright (c) 2008-2011 Todd Matthews & Steve Purcell
+
(function($) {
$.fn.tweet = function(o){
var s = $.extend({
View
17 htdocs/js/mikevalstar.js
@@ -9,10 +9,20 @@ var disqus_shortname = 'mikevalstar'; // required: replace example with your for
var disqus_identifier = 'bp_0';
var disqus_url = 'http://mikevalstar.com/';
-var MV = {};
+if(typeof MV == 'undefined') var MV = {};
MV.content = {};
-
+MV.imageReplace = function(){
+ if (window.devicePixelRatio >= 1.5) {
+ $('img.retina').each(function(index, item){
+ item = $(item);
+ if(!item.attr('src')) return; // no source on image
+ var path = item.attr('src');
+ var at_2x_path = path.replace(/\.\w+$/, function(match) { return "@2x" + match; });
+ item.attr('src', at_2x_path);
+ });
+ }
+}
$(function(){
// Initialize twitter feed
@@ -36,4 +46,7 @@ $(function(){
});
}
});
+
+ // Retina image replacement
+ MV.imageReplace();
});
View
BIN htdocs/usrimg/bp_104_hashbang.png
Deleted file not rendered
View
61 lib/AS3.js
@@ -0,0 +1,61 @@
+var awssum = require('awssum');
+var amazon = awssum.load('amazon/amazon');
+var S3 = awssum.load('amazon/s3').S3;
+var fs = require('fs');
+
+/*********************
+ Abstraction class for amazon S3
+*********************/
+
+var AS3 = module.exports = {
+ _connect: function(){
+
+ var s3 = new S3({
+ 'accessKeyId' : process.env.accessKeyId,
+ 'secretAccessKey' : process.env.secretAccessKey,
+ 'region' : amazon.US_EAST_1
+ });
+
+ return s3;
+ },
+
+ listImages:function(dir, callback){
+ s3 = this._connect();
+
+ var options = {
+ BucketName : 'mikevalstar',
+ MaxKeys : 200,
+ Prefix: 'img/' + dir
+ };
+
+ s3.ListObjects(options,function(err,data){
+ if(!err){
+ callback(err, data.Body.ListBucketResult);
+ }else{
+ callback(err);
+ }
+ });
+ },
+
+ uploadImage: function(source, dest, content_type, callback){
+ s3 = this._connect();
+
+ fs.stat(source, function(err, file_info) {
+ if (err) {
+ callback(err);
+ return;
+ }
+
+ var bodyStream = fs.createReadStream( source );
+ var params = {
+ BucketName : 'mikevalstar',
+ ObjectName : 'img/' + dest,
+ ContentType : content_type,
+ ContentLength : file_info.size,
+ Body : bodyStream
+ };
+
+ s3.PutObject(params, callback);
+ });
+ }
+};
View
201 lib/AdminPages.js
@@ -1,5 +1,10 @@
// Includes
-var crypto = require('crypto');
+var crypto = require('crypto'),
+ as3 = require('./AS3'),
+ fs = require('fs'),
+ path = require('path'),
+ im = require('imagemagick'),
+ flow = require('flow');
function hashString(value) {
hash = crypto.createHash('sha1');
@@ -29,6 +34,11 @@ AdminPages.prototype = {
app.post('/Admin/Post', function(req, res) { self.pagePostPost(req, res); } );
app.get ('/Admin/Post/:id', function(req, res) { self.pagePost(req, res); } );
+ // image related
+ app.get ('/Admin/Images', function(req, res) { self.images(req, res); } );
+ app.get ('/Admin/AJAX/Images', function(req, res) { self.ajaxImageList(req, res); } );
+ app.post ('/Admin/AJAX/Image', function(req, res) { self.imageAdd(req, res); } );
+
// misc.
app.get ('/Admin', function(req, res) { self.pageIndex(req, res); } );
}
@@ -95,7 +105,7 @@ AdminPages.prototype = {
res.render('admin/index', {
title: 'Admin Index',
- showFullNav: false
+ showAdminJS: true
});
}
@@ -109,7 +119,7 @@ AdminPages.prototype = {
res.render('admin/postlist', {
title: 'Post Listing',
posts: docs,
- showFullNav: false
+ showAdminJS: true
});
});
}
@@ -129,7 +139,7 @@ AdminPages.prototype = {
res.render('admin/post', {
title: req.params.id + ' - ' + row.title,
post: row,
- showFullNav: false
+ showAdminJS: true
});
});
@@ -152,16 +162,16 @@ AdminPages.prototype = {
sid : newid,
author : "mikevalstar@gmail.com",
title : "",
- img_lg : "",
- img_sm : "",
+ img_s3 : "",
+ img_retina : false,
content : "",
short : "",
group : "",
ext_link: "",
posted : "",
edited : "",
},
- showFullNav: false
+ showAdminJS: true
});
});
}
@@ -173,14 +183,13 @@ AdminPages.prototype = {
if(req.body.id && req.body.id != ""){
// old page
var blogpost = this.db.model('blogPost');
-
blogpost.update(
{_id: req.body.id},
{
sid : req.body.sid,
title : req.body.title,
- img_lg : req.body.img_lg,
- img_sm : req.body.img_sm,
+ img_s3 : req.body.img_s3,
+ img_retina : req.body.img_retina == 1 || false,
content : req.body.content,
short : req.body.short,
group : req.body.group,
@@ -218,8 +227,8 @@ AdminPages.prototype = {
sid : req.body.sid == "" ? parseInt(newid) : req.body.sid,
author : "mikevalstar@gmail.com",
title : req.body.title,
- img_lg : req.body.img_lg,
- img_sm : req.body.img_sm,
+ img_s3 : req.body.img_s3,
+ img_retina : req.body.img_retina == 1 || false,
content : req.body.content,
short : req.body.short,
group : req.body.group,
@@ -239,6 +248,174 @@ AdminPages.prototype = {
});
}
+ },
+
+ images: function(req, res){
+ if( !this._checkLogin(req, res) ) return;
+ // dispaly the page, its static, we'll populate with javascript
+ res.render('admin/images', { title: 'Image Listing', showAdminJS: true });
+ },
+
+ imageAdd: function(req, res){
+ if( !this._checkLogin(req, res) ) return;
+
+ // Gather all the relevent info about the file
+ var section = req.body.type;
+ var tmpfile = req.files.image.path,
+ content_type = req.files.image.type,
+ origname = req.files.image.name,
+ origext = path.extname(req.files.image.name);
+ var origbasename = path.basename(origname, origext);
+ var ext = '.jpeg';
+ switch(content_type){
+ case 'image/gif':
+ ext = '.gif';
+ break;
+ case 'image/jpg':
+ case 'image/jpeg':
+ ext = '.jpeg';
+ break;
+ case 'image/png':
+ ext = '.png';
+ break;
+ }
+
+ // Sizes we need/want for a given image based on type (@2x versions will also be generated)
+ var sizes = [];
+ switch(section){
+ case 'lead':
+ sizes = [{height: 300, width: 1100}, // Leader lg (on article page)
+ {height: 240, width: 884}, // Leader med (on article page)
+ {height: 182, width: 668}, // Leader tablet (on article page)
+
+ {height: 209, width: 770}, // Leader lg (on article list)
+ {height: 169, width: 620}, // Leader med (on article list)
+ {height: 129, width: 476}, // Leader tablet (on article list)
+
+ {height: 106, width: 388}]; // leader phone (article / list / lowres)
+ }
+
+ flow.exec(
+ // Get image info
+ function(){
+ im.identify(tmpfile, this)
+ },
+ // Resize Image
+ function(err, imageinfo){
+ if(!err){
+ // function to convert image
+ // Separate function to isolate variables for callback
+ function convert(dim, file, name, dest, crop, cb){
+ im.convert([file,
+ crop ? '-thumbnail' : '-resize',
+ crop ? dim + '^' : dim,
+ '-background', ext == '.jpeg' ? 'white' : 'transparent',
+ '-gravity', 'center',
+ '-extent', dim,
+ name],
+ function(result){ callback({source: name, destination: dest}); } );
+ }
+
+ // Special case thumbnail & 2x thumbnail
+ var callback = this.MULTI();
+ var thumbname = path.join( path.dirname(tmpfile), origbasename + '_thumb' + ext );
+ convert('150x150', tmpfile, thumbname, section + '/thumb/' + origbasename + ext, false, callback);
+
+ callback = this.MULTI();
+ thumbname = path.join( path.dirname(tmpfile), origbasename + '_thumb@2x' + ext );
+ convert('300x300', tmpfile, thumbname, section + '/thumb/' + origbasename + "@2x" + ext, false, callback);
+
+ // Generate all of the various sizes if applicable
+ for( var i = 0; i < sizes.length; i++ ) {
+ if( imageinfo.height >= sizes[i].height
+ && imageinfo.width >= sizes[i].width){
+
+ // Generate the regular sized image
+ var cb = this.MULTI();
+ var dimensions = sizes[i].width + 'x' + sizes[i].height;
+ var tmpname = path.join( path.dirname(tmpfile), origbasename + '_' + dimensions + ext );
+ var dest = path.join(section, dimensions, origbasename + ext);
+ convert(dimensions, tmpfile, tmpname, dest, true, cb);
+
+ // geneerate 2x images
+ if( imageinfo.height >= sizes[i].height *2
+ && imageinfo.width >= sizes[i].width *2){
+ var cb2x = this.MULTI();
+ var dimensions2x = (sizes[i].width * 2) + 'x' + (sizes[i].height * 2);
+ var tmpname2x = path.join( path.dirname(tmpfile), origbasename + '_' + dimensions + '@2x' + ext );
+ var dest2x = path.join(section, dimensions, origbasename + '@2x' + ext);
+ convert(dimensions2x, tmpfile, tmpname2x, dest2x, true, cb2x);
+ }
+ }
+ };
+
+ }// dont do anything and the loop exists on error
+ },
+ // Upload to S3
+ function(results){
+
+ // function to upload file to s3
+ // Separate function to isolate variables for callback
+ function upload(source, dest, cb){
+ as3.uploadImage(source,
+ dest,
+ content_type,
+ function(err, result){ cb(err, result, source); });
+ }
+
+ // Special case for original
+ upload(tmpfile,
+ section + '/orig/' + origbasename + ext,
+ this.MULTI());
+
+ for( var i = 0; i < results.length; i++ ) {
+ upload(results[i]['0'].source,
+ results[i]['0'].destination,
+ this.MULTI());
+ }
+ },
+ // Delete temp files
+ function(results){
+ // All processing is finished, delete the temp files
+ for( var i = 0; i < results.length; i++ ) {
+ fs.unlink(results[i][2]);
+ }
+
+ res.send({success: "Image resized and uploaded"}); // tell the browser it uploaded. so it can regen the page
+ }
+ );
+
+ },
+
+ ajaxImageList: function(req, res){
+ if( !this._checkLogin(req, res) ) return;
+
+ as3.listImages('lead/thumb', function(err, results){
+ if(!err){
+ if(results.Contents && results.Contents.length > 0){
+ var imgList = [];
+ for(var i = 0; i < results.Contents.length; i++){
+ var row = results.Contents[i];
+ if(row.Key[row.Key.length - 1] != "/" && path.basename(row.Key).indexOf('@2x') < 1 ){
+ imgList.push({
+ image: '//s3.amazonaws.com/mikevalstar/' + row.Key,
+ imageShort: path.basename(row.Key),
+ mod: row.LastModified,
+ size: row.Size
+ });
+ }
+ }
+
+ imgList.sort(function(a,b){ if(a.mod == b.mod){ return 0 } return a.mod > b.mod ? -1 : 1; }); // sort newest first
+
+ res.send({images: imgList});
+ }else{
+ res.send({notice: "0 results found"});
+ }
+ }else{
+ res.send({error: "There was an error with the request", details: err});
+ }
+ });
}
};
View
4 lib/Database.js
@@ -15,8 +15,8 @@ Database.prototype = {
sid : { type: Number, required: true, unique: true, index: true },
author : { type: String },
title : { type: String },
- img_lg : { type: String },
- img_sm : { type: String },
+ img_s3 : { type: String },
+ img_retina : { type: Boolean },
content : { type: String },
short : { type: String },
group : { type: String },
View
3 package.json
@@ -10,5 +10,8 @@
, "session-mongoose": ">= 0.0.1"
, "dateformat": ">= 0.0.1"
, "less-middleware": "*"
+ , "awssum": "*"
+ , "imagemagick": "*"
+ , "flow": "*"
}
}
View
9 views/admin/adminbar.jade
@@ -0,0 +1,9 @@
+.navbar.navbar-inverse
+ .navbar-inner
+ a.brand(href="/Admin") Admin Interface
+ .pull-right
+ ul.nav
+ li: a(href="/Admin/NewPost") New Post
+ ul.nav
+ li: a(href="/Admin/PostList") Posts
+ li: a(href="/Admin/Images") Images
View
14 views/admin/images.jade
@@ -0,0 +1,14 @@
+extends ../layout
+
+block content
+
+ include adminbar
+
+ .pull-right
+ .dropzone.dropimglead
+ span Drag a file here to upload
+
+ h2 Images
+ .row-fluid
+ .span12
+ #imageListFull
View
4 views/admin/index.jade
@@ -2,9 +2,7 @@ extends ../layout
block content
- h2 Admin
-
- h3 You are logged in
+ include adminbar
ul
li
View
44 views/admin/login.jade
@@ -1,25 +1,33 @@
extends ../layout
block content
-
- h2 Admin - Login
div.loginform
- form(method="post", action="/Admin/Login")
- h3 Login
+ form.form-horizontal(method="post", action="/Admin/Login")
+ legend Login
- - if(typeof(error_text) != 'undefined')
- div.error
- span=error_text
+ .control-group
+ label.control-label(for="inputEmail") Email
+ .controls
+ - if(typeof(email) != 'undefined')
+ input#inputEmail(type="text", name="email", placeholder="Email", value=email)
+ - else
+ input#inputEmail(type="text", name="email", placeholder="Email")
- span Login
- - if(typeof(email) != 'undefined')
- input(type="text", name="email", value=email)
- - else
- input(type="text", name="email")
- br
- span Password
- input(type="password", name="password")
- br
- span &nbsp;
- input(type="submit", value="Login")
+ - if(typeof(error_text) != 'undefined'){
+ .control-group.error
+ label.control-label(for="inputPassword") Password
+ .controls
+ input#inputPassword(type="password", name="password")
+ span.help-inline=error_text
+ - }else{
+ .control-group
+ label.control-label(for="inputPassword") Password
+ .controls
+ input#inputPassword(type="password", name="password")
+ - }
+
+
+ .control-group
+ .controls
+ input.btn.btn-inverse(type="submit", value="Login")
View
63 views/admin/post.jade
@@ -2,26 +2,49 @@ extends ../layout
block content
+ include adminbar
+
h2 Edit Post
- span.postid= post.id
+ small.postid= post.id
- form(method="post", action="/Admin/Post")
+ form.form-horizontal(method="post", action="/Admin/Post")
input(type="hidden", name="id", value=post.id)
- h3 ID
- input(type="text", name="sid", value=post.sid)
- h3 Title
- input(type="text", name="title", style="width: 100%;", value=post.title)
- h3 Group
- input(type="text", name="group", style="width: 100%;", value=post.group)
- h4 Image Large
- input(type="text", name="img_lg", style="width: 50%;", value=post.img_lg)
- h4 Image Small
- input(type="text", name="img_sm", style="width: 50%;", value=post.img_sm)
- h3 Content
- textarea(name="short", style="width: 100%; height: 5em;")= post.short
- textarea(name="content", style="width: 100%; height: 20em;")= post.content
- span.i All content is in jade format
- h4 Link to external content
- input(type="text", name="ext_link", style="width: 100%;", value=post.ext_link)
- br
- input(type="submit", value="Save")
+
+ .control-group
+ label.control-label(for="inputSID") ID
+ .controls
+ input#inputSID(type="text", name="sid", value=post.sid, style="width: 5em;")
+ .control-group
+ label.control-label(for="inputTitle") Title
+ .controls
+ input#inputTitle(type="text", name="title", value=post.title, style="width: 100%;")
+ .control-group
+ label.control-label(for="inputGroup") Group
+ .controls
+ input#inputGroup(type="text", name="group", value=post.group, style="width: 50%;")
+ .control-group
+ label.control-label(for="inputLeader") Leader Image
+ .controls
+ .input-append{
+ input#inputLeader(type="text", name="img_s3", value=post.img_s3, style="width: 20em;")
+ a.btn(href="#", class="imageSelector", data-fill="#inputLeader", data-port="#imageListSelector") Select Image
+ |
+ label.checkbox.inline
+ input#inputRetina(type="checkbox", name="img_retina", value="1", checked=post.img_retina)
+ | Retina
+ #imageListSelector
+ .control-group
+ label.control-label(for="inputShort") Content Short
+ .controls
+ textarea#inputShort(name="short", style="width: 100%; height: 5em;")= post.short
+ .control-group
+ label.control-label(for="inputContent") Content Full
+ .controls
+ textarea#inputContent(name="content", style="width: 100%; height: 20em;")= post.content
+ .control-group
+ label.control-label(for="inputExtLink") External Link
+ .controls
+ input#inputExtLink(type="text", name="ext_link", value=post.ext_link, style="width: 100%;")
+ .control-group
+ .controls
+ input.btn.btn-inverse(type="submit", value="Save")
View
10 views/admin/postlist.jade
@@ -2,9 +2,11 @@ extends ../layout
block content
- h2 Admin - Post Listing
+ include adminbar
- table.aPostList
+ a.btn(href="/Admin/NewPost") Create a new post
+
+ table.table.table-striped.table-hover
thead
tr
th Post ID
@@ -23,6 +25,4 @@ block content
| Internal
- }
td: time= item.posted
- - })
-
- a(href="/Admin/NewPost") Create a new post
+ - })
View
4 views/index.jade
@@ -18,8 +18,8 @@ block content
h5 Posted on
time(datetime=item.posted) #{item.posted_human}
- - if(item.img_sm != '')
- div.tc: img(src=item.img_sm)
+ - if(item.img_s3 && item.img_s3 != '')
+ div.tc: img(src="//s3.amazonaws.com/mikevalstar/img/lead/770x209/" + item.img_s3, class=item.img_retina ? "retina" : "")
!=item.short
View
31 views/layout.jade
@@ -1,3 +1,4 @@
+- if(typeof showAdminJS === 'undefined') showAdminJS = false;
!!! 5
html(lang="en")
head
@@ -18,34 +19,18 @@ html(lang="en")
link(rel='stylesheet', href='/css/style.min.css')
- script(type="text/javascript")
- (function() {
- var x = document.getElementsByTagName('script')[0];
- var s = document.createElement('script');
- s.type = 'text/javascript';
- s.async = true;
- s.src = 'http://code.jquery.com/jquery-1.8.2.min.js';
- x.parentNode.insertBefore(s, x);
-
- s = document.createElement('script');
- s.type = 'text/javascript';
- s.async = true;
- s.src = '/js/jquery.tweet.js';
- x.parentNode.insertBefore(s, x);
-
- s = document.createElement('script');
- s.type = 'text/javascript';
- s.async = true;
- s.src = '/js/mikevalstar.js';
- x.parentNode.insertBefore(s, x);
- })();
-
+ script(type="text/javascript", src='//code.jquery.com/jquery-1.8.2.min.js')
+ script(type="text/javascript", src='/js/jquery.tweet.js')
+ script(type="text/javascript", src='/js/mikevalstar.js')
+ -if(showAdminJS)
+ script(type="text/javascript", src='/js/admin.js')
+
script(type="text/javascript")
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-1984894-13']);
_gaq.push(['_setSiteSpeedSampleRate', 10]);
_gaq.push(['_trackPageview']);
-
+
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
View
4 views/post.jade
@@ -9,8 +9,8 @@ block content
h5 Posted on
time(datetime=post.posted) #{post.posted_human}
- - if(post.img_lg != '')
- #topImage.tc: img(src=post.img_lg)
+ - if(post.img_s3 && post.img_s3 != '')
+ #topImage.tc: img(src="//s3.amazonaws.com/mikevalstar/img/lead/1100x300/" + post.img_s3, class=post.img_retina ? "retina" : "")
- if(post.content == ''){
!=post.short

0 comments on commit 387c2cc

Please sign in to comment.
Something went wrong with that request. Please try again.