-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Features for Easy Web App Creation
Restructure Potcake for easy web app creation. Web apps can be created through two new objects. WebApp and WebAppSettings. Through them we provide the following features: - Django-style routing - Static file serving (with collection of files from multiple directories) - Django-style URL reversing - Middleware - Settings management Details: Revamp URL dispatching to provide an ergonomic API free of templates. Path parsing is now done at runtime which frees us from the struggles templates bring. Templates are great but use of them for central data structures forces user code to be templated. It also makes some API structures impossible to right. For example, with templates the user cannot store configuration as data prior to instantiating the WebApp if the configuration uses templates that need the WebApp. Also, each instantiation is a new type if the template arguments differ. This prevents storing template instantiations in a collection. We make heavy use of delegates for storing code to use an object instead of objects themselves. This is handy for storing disparate objects in a collection when they all are alike in the actions carried out using them. Add the ability to obtain a route path by supplying a pre-registered name and path arguments (reversing). The reversing function makes use of a new reference to the initialized app at runtime. Add toPath functions to path converters for converting path arguments to their string representations in paths. Return a common exception from path converters to aid signaling when a reversed path cannot be created. Use Variant instead of emplacing and cast for easier-to-use code. Rehash Router associative arrays for performance. Add static file handling via two approaches: - Single-directory approach where all files are stored in a single directory in development and production. - Collecting approach where static files are merged into one directory and served from a single routh path. Add `staticPath` method for building static paths in templates. Add WebApp.addRoutes for adding all routes at once using a collection. Make a trailing '/' optional when calling a route if the route's path was specified with a trailing '/' Streamline static file serving for the single directory case. The developer can configure serving via the settings object and all static serving for all cases is now done via serveStaticFiles. Wrap all modules in @safe.
- Loading branch information
1 parent
02638c6
commit 7a729d8
Showing
21 changed files
with
1,460 additions
and
306 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
name "collect-static-files-example" | ||
description "Demonstrates a web app that serves collected static files." | ||
|
||
dependency "potcake:web" path="../../" | ||
|
||
postBuildCommands "\"$DUB_TARGET_PATH\\$DUB_ROOT_PACKAGE_TARGET_NAME\" --collectstatic" platform="windows" | ||
postBuildCommands "\"$DUB_TARGET_PATH/$DUB_ROOT_PACKAGE_TARGET_NAME\" --collectstatic" platform="posix" |
Oops, something went wrong.