DG MS; made an imageUrl handlebars helper for assets served through handlebars templates.

This commit is contained in:
danielgrippi 2012-01-26 17:04:03 -08:00
parent 48941fbae1
commit fa1ee731af
4 changed files with 20 additions and 6 deletions

View file

@ -87,6 +87,9 @@
Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}"); Diaspora.I18n.loadLocale(#{get_javascript_strings_for(I18n.locale).to_json}, "#{I18n.locale}");
Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}"; Diaspora.Page = "#{params[:controller].camelcase}#{params[:action].camelcase}";
:javascript
app.baseImageUrl("#{ENV['ASSET_HOST']}")
- if current_user - if current_user
:javascript :javascript
app.user( app.user(

View file

@ -2,7 +2,7 @@
<!-- need access to post --> <!-- need access to post -->
{{#if ownComment}} {{#if ownComment}}
<a href="#" class="delete comment_delete" title="{{t "delete"}}"> <a href="#" class="delete comment_delete" title="{{t "delete"}}">
<img alt="Deletelabel" src="/images/deletelabel.png" /> <img alt="Deletelabel" src="{{imageUrl "/images/deletelabel.png"}}" />
<a/> <a/>
{{/if}} {{/if}}
</div> </div>

View file

@ -1,7 +1,7 @@
<div class="container" style="position:relative;"> <div class="container" style="position:relative;">
<a href="/stream"> <a href="/stream">
<img alt="Logo_small" class="diaspora_header_logo" height="38px" width="65px" src="/images/header-logo.png" /> <img alt="Logo_small" class="diaspora_header_logo" height="38px" width="65px" src="{{imageUrl "/images/header-logo.png"}}" />
</a> </a>
<div id="global_search"> <div id="global_search">
@ -13,13 +13,13 @@
<div id="nav_badges"> <div id="nav_badges">
<div class="badge" id="home_badge"> <div class="badge" id="home_badge">
<a href="/stream" title="{{t "header.home"}}"><img alt="Home" src="/images/icons/home_grey.png"> <a href="/stream" title="{{t "header.home"}}"><img alt="Home" src="{{imageUrl "/images/icons/home_grey.png"}}" />
</a> </a>
</div> </div>
<div class="badge" id="notification_badge"> <div class="badge" id="notification_badge">
<a href="/notifications" title="{{t "header.notifications"}}"> <a href="/notifications" title="{{t "header.notifications"}}">
<img alt="{{t "header.notifications"}}" id="notification-flag" src="/images/icons/notifications_grey.png"> <img alt="{{t "header.notifications"}}" id="notification-flag" src="{{imageUrl "/images/icons/notifications_grey.png"}}" />
<div class="badge_count {{#unless current_user.notifications_count}} hidden {{/unless}}"> <div class="badge_count {{#unless current_user.notifications_count}} hidden {{/unless}}">
{{current_user.notifications_count}} {{current_user.notifications_count}}
</div> </div>
@ -28,7 +28,7 @@
<div class="badge" id="message_inbox_badge"> <div class="badge" id="message_inbox_badge">
<a href="/conversations" title="{{t "header.messages"}}"> <a href="/conversations" title="{{t "header.messages"}}">
<img alt="{{t "header.messages"}}" src="/images/icons/mail_grey.png"> <img alt="{{t "header.messages"}}" src="{{imageUrl "/images/icons/mail_grey.png"}}" />
<div class="badge_count {{#unless current_user.unread_messages_count}} hidden {{/unless}}"> <div class="badge_count {{#unless current_user.unread_messages_count}} hidden {{/unless}}">
{{current_user.unread_messages_count}} {{current_user.unread_messages_count}}
</div> </div>
@ -55,7 +55,7 @@
<div class="notifications"> <div class="notifications">
<div class="ajax_loader"> <div class="ajax_loader">
<img alt="Ajax-loader" src="/images/ajax-loader.gif"> <img alt="Ajax-loader" src="{{imageUrl "/images/ajax-loader.gif"}}">
</div> </div>
</div> </div>
</div> </div>

View file

@ -9,6 +9,11 @@ var app = {
return this._user || false return this._user || false
}, },
baseImageUrl: function(baseUrl){
if(baseUrl) { return this._baseImageUrl = baseUrl }
return this._baseImageUrl || ""
},
initialize: function() { initialize: function() {
app.router = new app.Router(); app.router = new app.Router();
@ -32,8 +37,14 @@ var app = {
}; };
$(function() { $(function() {
Handlebars.registerHelper('t', function(){ Handlebars.registerHelper('t', function(){
return Diaspora.I18n.t(arguments[0], jQuery.parseJSON(arguments[1])) return Diaspora.I18n.t(arguments[0], jQuery.parseJSON(arguments[1]))
}) })
Handlebars.registerHelper('imageUrl', function(path){
return app.baseImageUrl() + path;
})
app.initialize(); app.initialize();
}); });