require 'noumenon/version' require 'noumenon/string_extensions' require 'facets' require 'rack/builder' # @api public module Noumenon autoload :AssetRepository, 'noumenon/asset_repository' autoload :Core, 'noumenon/core' autoload :ContentRepository, 'noumenon/content_repository' autoload :Template, 'noumenon/template' autoload :Theme, 'noumenon/theme' autoload :Spec, 'noumenon/spec' # Starts Noumenon serving, this will usually be called from a config.ru file # something like this: # # Noumenon.content_repository = Noumenon::Repository::FileSystem.new("/home/noumenon/content") # Noumenon.theme = Noumenon::Theme.load("/home/noumenon/theme") # # run Noumenon.server # # While you can also just use an instance Noumenon::Core, keep in mind that it won't # have the full Rack middleware stack, and so some functionality such as serving assets # from themes won't be available. # # @api public # @return [ Rack::Builder ] the Rack stack to serve a Noumenon site def self.server Rack::Builder.new do use Noumenon::Theme::AssetsMiddleware run Noumenon::Core end end # Returns the current content repository. # # @api public # @return [ Noumenon::Repository, #get, #put ] def self.content_repository @content_repository end # Sets the repository to load site content from. # # @api public # @param [ Noumenon::Repository, #get, #put ] repository the repository to use def self.content_repository=(repository) @content_repository = repository end # Returns the current asset repository. If one hasn't been set then the content repository will be returned. # # @api public # @return [ Noumenon::Repository, #get_asset, #save_asset ] def self.asset_repository @asset_repository || content_repository end # Sets the current asset repository. If you want to return to using the default content repository set to nil. # # @api public # @param [ Noumenon::Repository, #get_asset, #save_asset ] repository The repository to use for assets. def self.asset_repository=(repository) @asset_repository = repository end # Returns the current theme # # @api public # @return [ Noumenon::Theme ] the current theme def self.theme @theme end # Set the current theme. # # If provided with a [ Noumenon::Theme ] object then it will set that, otherwise # it will convert the argument to a string, and attempt to find a loaded theme with # that name. # # @api public # @param [ Noumenon::Theme, #to_s ] theme either a theme object, or the name of a loaded theme # @return [ Noumenon::Theme, nil ] the specified theme, or nil if it could not be found def self.theme=(theme) if theme.is_a? Noumenon::Theme @theme = theme else raise ArgumentError.new("The theme '#{theme}' has not been loaded.") unless Noumenon::Theme.themes.key?(theme) self.theme = Noumenon::Theme.themes[theme] end @theme end end