* controller.Users.current() now returns an http_url if one is configured in config/Common.py
* changed controller.Users and controller.Root constructor arguments to support this. * Updated INSTALL document accordingly. * Client now will prepend this new http_url variable to the logout link.
This commit is contained in:
parent
ef53bb8159
commit
0ac518e395
6
INSTALL
6
INSTALL
|
@ -35,9 +35,11 @@ mode doesn't support auto-reload, and logging goes to file (luminotes.log)
|
|||
instead of the console, but performance should be better than in development
|
||||
mode.
|
||||
|
||||
If you want to use SSL, edit config/Common.py and change the value of
|
||||
luminotes.https_url to the URL of your SSL server. For instance:
|
||||
If you want to use SSL, edit config/Common.py and change the values of
|
||||
luminotes.http_url and luminotes.https_url based on the domain you're using.
|
||||
For instance:
|
||||
|
||||
"luminotes.http_url": "http://luminotes.com",
|
||||
"luminotes.https_url": "https://luminotes.com",
|
||||
|
||||
Then you'll need to configure your web server to forward requests for
|
||||
|
|
|
@ -15,6 +15,7 @@ settings = {
|
|||
"encoding_filter.encoding": "utf-8",
|
||||
"decoding_filter.on": True,
|
||||
"decoding_filter.encoding": "utf-8",
|
||||
"luminotes.http_url": "",
|
||||
"luminotes.https_url": "",
|
||||
},
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ from view.Not_found_page import Not_found_page
|
|||
|
||||
|
||||
class Root( object ):
|
||||
def __init__( self, scheduler, database ):
|
||||
def __init__( self, scheduler, database, settings ):
|
||||
self.__scheduler = scheduler
|
||||
self.__database = database
|
||||
self.__notebooks = Notebooks( scheduler, database )
|
||||
self.__users = Users( scheduler, database )
|
||||
self.__users = Users( scheduler, database, settings[ u"global" ].get( u"luminotes.http_url", u"" ) )
|
||||
|
||||
@expose( view = Main_page )
|
||||
def index( self ):
|
||||
|
|
|
@ -103,9 +103,10 @@ def update_auth( function ):
|
|||
|
||||
|
||||
class Users( object ):
|
||||
def __init__( self, scheduler, database ):
|
||||
def __init__( self, scheduler, database, http_url ):
|
||||
self.__scheduler = scheduler
|
||||
self.__database = database
|
||||
self.__http_url = http_url
|
||||
|
||||
@expose( view = Json )
|
||||
@update_auth
|
||||
|
@ -227,6 +228,7 @@ class Users( object ):
|
|||
yield dict(
|
||||
user = user,
|
||||
notebooks = notebooks,
|
||||
http_url = self.__http_url,
|
||||
)
|
||||
|
||||
scheduler = property( lambda self: self.__scheduler )
|
||||
|
|
|
@ -13,7 +13,8 @@ class Test_controller( object ):
|
|||
cherrypy.lowercase_api = True
|
||||
self.scheduler = Scheduler()
|
||||
self.database = Database( self.scheduler, database_path = None )
|
||||
cherrypy.root = Root( self.scheduler, self.database )
|
||||
self.settings = { u"global": { u"luminotes.http_url" : u"http://luminotes.com" } }
|
||||
cherrypy.root = Root( self.scheduler, self.database, self.settings )
|
||||
cherrypy.config.update( Common.settings )
|
||||
cherrypy.config.update( { u"server.log_to_screen": False } )
|
||||
cherrypy.server.start( init_only = True, server_class = None )
|
||||
|
|
|
@ -139,9 +139,11 @@ class Test_users( Test_controller ):
|
|||
|
||||
assert result[ u"user" ] == self.user
|
||||
assert result[ u"notebooks" ] == [ self.anon_notebook ] + self.notebooks
|
||||
assert result[ u"http_url" ] == self.settings[ u"global" ].get( u"luminotes.http_url" )
|
||||
|
||||
def test_current_without_login( self ):
|
||||
result = self.http_get( "/users/current" )
|
||||
|
||||
assert result[ u"user" ].username == "anonymous"
|
||||
assert result[ u"notebooks" ] == [ self.anon_notebook ]
|
||||
assert result[ u"http_url" ] == self.settings[ u"global" ].get( u"luminotes.http_url" )
|
||||
|
|
14
luminotes.py
14
luminotes.py
|
@ -9,18 +9,20 @@ def main( args ):
|
|||
scheduler = Scheduler()
|
||||
database = Database( scheduler, "data.db" )
|
||||
|
||||
cherrypy.lowercase_api = True
|
||||
root = Root( scheduler, database )
|
||||
cherrypy.root = root
|
||||
|
||||
cherrypy.config.update( Common.settings )
|
||||
|
||||
if len( args ) > 0 and args[ 0 ] == "-d":
|
||||
from config import Development
|
||||
cherrypy.config.update( Development.settings )
|
||||
settings = Development.settings
|
||||
else:
|
||||
from config import Production
|
||||
cherrypy.config.update( Production.settings )
|
||||
settings = Production.settings
|
||||
|
||||
cherrypy.config.update( settings )
|
||||
|
||||
cherrypy.lowercase_api = True
|
||||
root = Root( scheduler, database, cherrypy.config.configMap )
|
||||
cherrypy.root = root
|
||||
|
||||
if scheduler.shutdown not in cherrypy.server.on_stop_server_list:
|
||||
cherrypy.server.on_stop_server_list.append( scheduler.shutdown )
|
||||
|
|
|
@ -68,7 +68,7 @@ Wiki.prototype.display_user = function ( result ) {
|
|||
replaceChildNodes( "user_area", span );
|
||||
appendChildNodes( span, "logged in as " + result.user.username );
|
||||
appendChildNodes( span, " | " );
|
||||
appendChildNodes( span, createDOM( "a", { "href": "/", "id": "logout_link" }, "logout" ) );
|
||||
appendChildNodes( span, createDOM( "a", { "href": result.http_url + "/", "id": "logout_link" }, "logout" ) );
|
||||
|
||||
var self = this;
|
||||
connect( "recent_notes_link", "onclick", function ( event ) {
|
||||
|
|
Reference in New Issue