summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2018-06-17Validate::Interop::coerce_for_json(): Add "unknown" config option + inherit ↵Yorhel1-4/+13
that from schema This allows doing some basic normalization (i.e. removing keys) from the generated JSON.
2018-06-10Add experimental TUWF::Validate::Interop moduleYorhel2-18/+147
2018-06-05Convert README to markdown + update links to repoYorhel1-1/+1
2018-05-13Add docs for TUWF::ValidateYorhel2-1/+576
2018-05-12Log reqJSON() on errorYorhel1-1/+4
2018-05-11TUWF::Validate: Add enum validationYorhel1-0/+5
2018-04-17TUWF::Request: Fix reqParams() and reqGets() with zero-but-defined inputYorhel1-4/+4
Broken in previous commit.
2018-04-15Integrate TUWF::Validate with the rest of TUWFYorhel6-17/+168
- Add a 'custom_validations' setting - Add tuwf->compile() to compile with that setting - Add tuwf->validate() as alternative to formValidate() The new tuwf->validate() uses internal state of TUWF::Request, which had to be changed a bit to allow for more efficient validation. Nested schemas in TUWF::Validate now also accept compiled schemas. This stuff totally needs more documentation.
2018-04-14Add experimental TUWF::Validate moduleYorhel2-9/+376
This should replace kv_validate() in the future. It's much more generic and easier to extend. Inspiration drawn from both kv_validate() and Brannigan.
2018-02-18Year + Version bump for 1.2v1.2Yorhel13-13/+13
2018-02-18Actually refer to TUWF::Intro from somewhereYorhel1-1/+4
2018-02-17Add a TUWF::IntoYorhel1-0/+304
2018-02-09TUWF::XML: Small performance improvement of xml_escape()Yorhel2-8/+6
I've tried various things to make TUWF::XML faster, but so far this is the only change that actually has some effect. Can shave off about 1% to 3% of the page load time for pages that are heavy on TUWF::XML usage. And '>' totally doesn't need to be escaped.
2018-02-09resJSON: Fix double UTF-8 encodingYorhel1-2/+1
JSON::XS::encode_json() already does UTF-8 encoding for us, so we need to treat its return value as binary.
2018-02-05Add tuwf->done and tuwf->pass, change error & before hook handlingYorhel4-76/+167
This changes the way that before hooks signal whether to continue processing or not, and is a breaking change for code that uses before hooks with a false return value. This change does not affect the pre_request_handler, so only code using the git version of TUWF is affected. This more generic control flow handling now also permits request handlers for overlapping URL regexes, and tuwf->pass can be used to pass control to subsequent handlers.
2018-02-02Actually honor the import_modules settingYorhel1-3/+3
2018-01-31Add import_modules settingYorhel2-23/+60
2018-01-30Add dbVal()Yorhel2-10/+26
2018-01-22A few more common web MIMEsYorhel1-1/+12
2018-01-05Add .svg mimeYorhel1-0/+1
2018-01-02TUWF::XML: Remove deprecated <menu> tagYorhel2-4/+4
I think I should go over the entire tag list again before the next stable release...
2018-01-02TUWF::XML: Add <main> tagYorhel2-4/+4
Apparently I wasn't using a full html5 reference. Or rather, html5 is still quite a living standard.
2017-12-28TUWF::XML: Fix 'pretty' formatting + disallow end() closing parent tagsYorhel1-4/+9
Html; Head sub { End; # this would previously generate </html>, now it's an error. };
2017-12-28doc/TUWF::XML: Use two-space indents in examplesYorhel1-22/+22
2017-12-28TUWF::XML: Re-add "xml" to export optionsYorhel1-1/+1
Fixes an omission of 35776908b286b3f31a7d14f745f5ec6641c97fd6
2017-12-27doc: Add some more "see also" modules to TUWF::XMLYorhel1-0/+4
2017-12-27TUWF::XML: Support multiple function naming flavorsYorhel2-79/+144
Read: "I've no clue which style is best and everyone has their own opinions, so let's just support everything!" This is a breaking change for the :html5 group, but that group was only added recently and did not yet make it into a stable TUWF release, so there's little actual breakage.
2017-12-26doc: Note a limitation of reqProtocol()Yorhel1-0/+5
2017-12-26TUWF::Request: Fixup: Don't decode_utf8 an ENV var + check POST param namesYorhel1-2/+3
Apparently %ENV doesn't like it when you decode_utf8() in-place, which is, admittedly, not too surprising.
2017-12-26TUWF::Response: Set relative Location in resRedirect()Yorhel2-4/+4
This fixes redirects in the scenario where the reqBaseURI() is not correct, which may happen if there is a HTTPS-terminating proxy in between that TUWF is not aware if (i.e. reqProtocol() is wrong) or when the site is running on a non-standard port and this is not reflected in reqHost(). I've always found the absolute Location header a silly requirement, so I'm glad that RFC 7231 now allows a relative URI.
2017-12-26TUWF::Request: Check for control characters on all client inputYorhel1-10/+18
Seems much safer. I've not tested this patch as well as I'd like, I'll do some more testing later to see if I broke something.
2017-12-24TUWF::Request: Disallow ASCII control codes in urlencoded dataYorhel1-0/+3
This only catches trivial malicious url-encoding attacks; Such control codes can still get in through multipart form data or perhaps even URLs. I'll see if I should protect against those other injection methods, too.
2017-12-24Spice up the default error pages a bitYorhel1-13/+37
2017-12-24TUWF::XML: Add some references to similar modulesYorhel1-0/+7
2017-12-17Don't call resInit from resJSONYorhel2-5/+2
For the same reason that I removed the resInit call from resRedirect.
2017-12-16Documentation fixes and updatesYorhel4-64/+46
I removed the part about backward compatibility. Not that I will now fully guarantee that there won't be any breaking changes, but there's a bit too much TUWF-using code around that breaking major stuff is only going to cause me a lot of work.
2017-12-16TUWF::XML: Add "mkclass" utility functionYorhel2-1/+27
2017-12-16TUWF::XML: Add HTML5 tagsYorhel2-44/+80
There are many of them, and some may clash with commonly exported functions by other modules. So instead of ucfirst()ing only a few special ones, I decided to be consistend and ucfirst everything. It's slightly uglier, though. :(
2017-12-16TUWF::XML: Add HTML5 doctype and use it by defaultYorhel2-8/+17
This is kind-of a breaking change, but the HTML5 doctype is more compatible than xhtml1-strict. This change is a bit silly when everything else in TUWF::XML is still built for XHTML rather than HTML5, but I'll add some proper HTML5 support in a bit.
2017-12-16TUWF::XML: Add support for a more functional alternative to end()Yorhel2-10/+53
2017-12-15Fix handling of DBD drivers that don't set ParamValuesYorhel1-2/+2
Such as DBD::SQLite. Which is quite a pity, because param logging is pretty damn useful. I'll see if it's easy to write a workaround for.
2017-12-15TUWF::DB: Suppress "redefined" warningYorhel1-0/+1
2017-12-15Don't try to load HTTP::Server::Simple when not necessaryYorhel1-1/+1
2017-12-10Add TUWF::hook() + fix some error handling casesYorhel2-24/+90
The primary motivation behind TUWF::hook() is to allow individual modules to register their own hooks, without requiring some centralized coordination. While I was at it, I also noticed some odd behaviour around the old post_request_handler and error_*_handlers, in which the response was not even initialized in some cases. These changes should guarantee that a response has always been initialized whenever any handler is called, and that a dbCommit or dbRollback is always performed as appropriate.
2017-12-10Add logging and profiling to tuwf->dbh directlyYorhel2-24/+57
This changes the format of the 'log_queries' logs a bit, in order to support non-numeric bind parameters. It also changes the structure of the tuwf->{_TUWF}{queries} array, which will break some debugging code in VNDB. The primary goal of this change is to make it easier to use TUWF with other modules on CPAN. The following should now work, without losing the logging & profiling that TUWF::DB offers: use TUWF; use SQL::Yapp dbh => sub { tuwf->dbh }; sub somefunc { my @usernames = sqlFetch{SELECT username FROM users}; };
2017-12-10Store route handlers in $TUWF::OBJ + add error checking in TUWF::anyYorhel1-7/+10
This moves *all* of an applications config & state into the TUWF object, thus making it possible (but still quicky) to host multiple sites in one process by assigning different objects to $TUWF::OBJ. And while I'm normally not a huge fan of run-time checking of function arguments, the TUWF::any() function typically is only ever called at program initialization. This may catch some bugs that might otherwise be a pain to debug.
2017-12-09Add sexier replacements for TUWF::register()Yorhel4-49/+132
Once again inspired by Dancer2. The main improvements over TUWF::register() are: - Support for other HTTP methods than HEAD/GET/POST - HTTP method filtering in the routing code - Differentiate between literal and regex routes - Mandate 'tuwf->capture()' - Include the leading slash, to make it more explicit that it matches the entire path. I've wanted to make that last change back in 55cbbb319a135dbddfbfdd989bc0cb364edef81d, but couldn't because that would break a lot of code. TUWF::register() still works like it used to, so these additions shouldn't break anything.
2017-12-09Add a default-exported tuwf() DSL-like functionYorhel2-1/+22
Another inspiration from Dancer2. While Dancer2 exports a whole bunch of such functions, TUWF's functionality is already mostly contained in a single object, so a single function will do nicely.
2017-12-09Add $self->capture() method to extract route capturesYorhel2-3/+33
(Inspired by Dancer2's captures())
2017-12-09Use "local" to disable $SIG{__WARN__} in log handlerYorhel1-3/+1
Just a minor cleanup.