Shared folder asset handling

fixes #1659, fixes #1668

- removed relative asset url from css
- added asset helper to client
- updated references to shared assets
- added functional tests
This commit is contained in:
Hannah Wolfe 2013-12-27 15:12:24 +00:00
parent 4b491fbd6e
commit faa50b09b9
3 changed files with 21 additions and 3 deletions

View File

@ -209,7 +209,6 @@
display: block;
width: 110px;
height: 110px;
background-image: url(/shared/img/user-image.png);
background-size: cover;
background-position: center center;
border-radius: 100%;

View File

@ -32,4 +32,22 @@
Handlebars.registerHelper('url', function () {
return Ghost.paths.subdir;
});
Handlebars.registerHelper('asset', function (context, options) {
var output = '',
isAdmin = options && options.hash && options.hash.ghost;
output += Ghost.paths.subdir + '/';
if (!context.match(/^shared/)) {
if (isAdmin) {
output += 'ghost/';
} else {
output += 'assets/';
}
}
output += context;
return new Handlebars.SafeString(output);
});
}());

View File

@ -9,7 +9,8 @@
<section class="content no-padding">
<header class="user-profile-header">
<img id="user-cover" class="cover-image" src="{{#if cover}}{{cover}}{{else}}/shared/img/user-cover.png{{/if}}" title="{{name}}'s Cover Image"/>
<img id="user-cover" class="cover-image" src="{{#if cover}}{{cover}}{{else}}{{asset "shared/img/user-cover.png"}}{{/if}}" title="{{name}}'s Cover Image"/>
<a class="edit-cover-image js-modal-cover button" href="#">Change Cover</a>
</header>
@ -18,7 +19,7 @@
<fieldset class="user-details-top">
<figure class="user-image">
<div id="user-image" class="img" {{#if image}}style="background-image: url({{image}});"{{/if}} href="#"><span class="hidden">{{name}}'s Picture</span></div>
<div id="user-image" class="img" style="background-image: url({{#if image}}{{image}}{{else}}{{asset "shared/img/user-image.png"}}{{/if}});" href="#"><span class="hidden">{{name}}'s Picture</span></div>
<a href="#" class="edit-user-image js-modal-image">Edit Picture</a>
</figure>