Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

more user system, logo, uservoice

  • Loading branch information...
commit 334e0c053f41f752f8b309f26b06ad06a9044cb3 1 parent e2df914
Steve Coast authored
37 app/controllers/application_controller.rb
View
@@ -1,3 +1,40 @@
class ApplicationController < ActionController::Base
protect_from_forgery
+
+ protected
+
+ def authorize
+ @user = User.find_by_id(session[:user_id])
+ end
+
+ def require_user
+ authorize
+ redirect_to new_session_path unless @user
+ end
+
+ def authorize_api
+ user, pass = get_auth_data
+
+ @user = User.authenticate(user, pass)
+
+ end
+
+ private
+
+ def get_auth_data
+ if request.env.has_key? 'X-HTTP_AUTHORIZATION' # where mod_rewrite might have put it
+ authdata = request.env['X-HTTP_AUTHORIZATION'].to_s.split
+ elsif request.env.has_key? 'REDIRECT_X_HTTP_AUTHORIZATION' # mod_fcgi
+ authdata = request.env['REDIRECT_X_HTTP_AUTHORIZATION'].to_s.split
+ elsif request.env.has_key? 'HTTP_AUTHORIZATION' # regular location
+ authdata = request.env['HTTP_AUTHORIZATION'].to_s.split
+ end
+ # only basic authentication supported
+ if authdata and authdata[0] == 'Basic'
+ user, pass = Base64.decode64(authdata[1]).split(':',2)
+ end
+ return [user, pass]
+ end
+
+
end
2  app/controllers/points_controller.rb
View
@@ -1,4 +1,6 @@
class PointsController < ApplicationController
+ before_filter :require_user, :only => [:new, :edit]
+
# GET /points
# GET /points.xml
def index
39 app/views/layouts/application.html.erb
View
@@ -7,21 +7,50 @@
</head>
<body>
-<%= link_to 'home', '/' %>
-
-<% if session[:user_id] %>
+<div style="float:right;">
+<% if @user %>
you are logged in
<% else %>
<%= link_to 'create acct', new_user_path %> |
<%= link_to 'login', new_session_path %>
<% end %>
+</div>
+<div>
+<a href="/"><img src="/images/logo.jpg" border="0"></a>
+</div>
-<h1>Transiki</h1>
+<%= yield %>
+<!-- user voice code -->
+
+<script type="text/javascript">
+ var uservoiceOptions = {
+ /* required */
+key: 'transiki',
+ host: 'transiki.uservoice.com',
+ forum: '82883',
+ showTab: true,
+ /* optional */
+ alignment: 'right',
+ background_color:'#f00',
+ text_color: 'white',
+ hover_color: '#06C',
+ lang: 'en'
+ };
+
+function _loadUserVoice() {
+ var s = document.createElement('script');
+ s.setAttribute('type', 'text/javascript');
+ s.setAttribute('src', ("https:" == document.location.protocol ? "https://" : "http://") + "cdn.uservoice.com/javascripts/widgets/tab.js");
+ document.getElementsByTagName('head')[0].appendChild(s);
+}
+_loadSuper = window.onload;
+window.onload = (typeof window.onload != 'function') ? _loadUserVoice : function() { _loadSuper(); _loadUserVoice(); };
+</script>
+
-<%= yield %>
</body>
</html>
4 app/views/site/index.html.erb
View
@@ -1,6 +1,8 @@
-<p>This is <b>very alpha</b> and there is not much to see yet. Transiki is a wiki of transit data. Think a blend of google transit and openstreetmap.
+<p>This is <b>very alpha</b> and there is not much to see yet unless you are a coder. Transiki is a wiki of transit data. Think a blend of google transit and openstreetmap.
<p>You can look at the <a href="http://blog.transiki.org/">blog</a> and <a href="http://groups.google.com/group/transiki">mailing list</a> and <a href="http://github.com/SteveC/transiki/">code</a>.
+<% if @user %>
<p><%= link_to 'new point', new_point_path %>
+<% end %>
BIN  public/images/logo.jpg
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.