diff --git a/INSTALL b/INSTALL index 80a75fd..2e8a91e 100644 --- a/INSTALL +++ b/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 diff --git a/config/Common.py b/config/Common.py index ff52354..852e9c8 100644 --- a/config/Common.py +++ b/config/Common.py @@ -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": "", }, } diff --git a/controller/Root.py b/controller/Root.py index db849e3..ad6b1a9 100644 --- a/controller/Root.py +++ b/controller/Root.py @@ -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 ): diff --git a/controller/Users.py b/controller/Users.py index 9d52b85..a7907ee 100644 --- a/controller/Users.py +++ b/controller/Users.py @@ -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 ) diff --git a/controller/test/Test_controller.py b/controller/test/Test_controller.py index 478658a..c9dc021 100644 --- a/controller/test/Test_controller.py +++ b/controller/test/Test_controller.py @@ -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 ) diff --git a/controller/test/Test_users.py b/controller/test/Test_users.py index 851ed92..2523166 100644 --- a/controller/test/Test_users.py +++ b/controller/test/Test_users.py @@ -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" ) diff --git a/luminotes.py b/luminotes.py index 446f649..2da51a1 100644 --- a/luminotes.py +++ b/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 ) diff --git a/static/js/Wiki.js b/static/js/Wiki.js index ef123d2..d949a62 100644 --- a/static/js/Wiki.js +++ b/static/js/Wiki.js @@ -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 ) {