First version of showing uploaded logo. Need to be improved.

This commit is contained in:
Martin Edenhofer 2014-11-17 11:39:35 +01:00
parent 0dd1ed5d6e
commit 0415a8a298
3 changed files with 44 additions and 1 deletions

View file

@ -2,7 +2,7 @@
<p><%- @T( 'Login with %s', @C( 'fqdn' ) ) %></p> <p><%- @T( 'Login with %s', @C( 'fqdn' ) ) %></p>
<div class="hero-unit"> <div class="hero-unit">
<img class="logo" src="<%= @C('image_path') + '/' + 'company-logo.png' %>" alt="<%= @C( 'product_name' ) %>"> <img class="logo" src="<%= @C('api_path') + '/sessions/logo' %>" alt="<%= @C( 'product_name' ) %>">
<form id="login"> <form id="login">
<div class="form-group"> <div class="form-group">
<label for="username"><%- @Ti( 'Username / email' ) %></label> <label for="username"><%- @Ti( 'Username / email' ) %></label>

View file

@ -278,4 +278,46 @@ class SessionsController < ApplicationController
SessionHelper::destroy( params[:id] ) SessionHelper::destroy( params[:id] )
render :json => {} render :json => {}
end end
=begin
Resource:
GET /api/v1/sessions/logo
Response:
<IMAGE>
Test:
curl http://localhost/api/v1/sessions/logo
=end
def logo
# cache image
#response.headers['Expires'] = 1.year.from_now.httpdate
#response.headers["Cache-Control"] = "cache, store, max-age=31536000, must-revalidate"
#response.headers["Pragma"] = "cache"
# find logo
list = Store.list( :object => 'System::Logo', :o_id => 2 )
if list && list[0]
file = Store.find( list[0] )
send_data(
file.content,
:filename => file.filename,
:type => file.preferences['Content-Type'],
:disposition => 'inline'
)
return
end
# serve default image
send_data(
'',
:filename => '',
:type => 'image/gif',
:disposition => 'inline'
)
end
end end

View file

@ -15,6 +15,7 @@ Zammad::Application.routes.draw do
match api_path + '/sessions/switch/:id', :to => 'sessions#switch_to_user', :via => :get match api_path + '/sessions/switch/:id', :to => 'sessions#switch_to_user', :via => :get
match api_path + '/sessions/switch_back', :to => 'sessions#switch_back_to_user', :via => :get match api_path + '/sessions/switch_back', :to => 'sessions#switch_back_to_user', :via => :get
match api_path + '/sessions', :to => 'sessions#list', :via => :get match api_path + '/sessions', :to => 'sessions#list', :via => :get
match api_path + '/sessions/logo', :to => 'sessions#logo', :via => :get
match api_path + '/sessions/:id', :to => 'sessions#delete', :via => :delete match api_path + '/sessions/:id', :to => 'sessions#delete', :via => :delete
end end