Skip to content

Instantly share code, notes, and snippets.

@briandfoy
Last active May 19, 2020
Embed
What would you like to do?
Mojolicious Web Applications book outline
I'm not committing to the book just yet, but I'm thinking about what the outline would be.
I'm thinking about running another Kickstarter if I can find a major sponsor like I did
last time. Email me if you might be that person.
The basic idea is a tutorial book on writing that would start from scratch and build up.
This is specifically not a reference book that covers every aspect of Mojolicious. The
trick is to figure out all the topics that should be in the book and how to introduce them
gradually. Most topics should be relevant to most of the audience, while uncommon tasks
or lightly used features might not show up at all.
The User-Agent stuff is already in Mojolicious Web Clients. (https://amzn.to/2P5hkmP or https://leanpub.com/mojo_web_clients)
And, I have an eye on a separate websockets book.
* Random stuff that needs a home
+ web security (CSRF, etc)
+ javascript thingies (React, whatever)
+ Single page applications
* Introduction
+ Installing
* Hello World
+ using mojo to create an app
+ Mojo Lite
+ testing
* Writing a simple static file server
+ docker?
+ logging
+ more testing
* Templated files
+ MVC stuff
+ more stuff about rendering
+ wrappers, headers, footers, whatever
+ more testing
* Form handling routes
+ handling get
+ handling post
+ more testing
* Mojo not lite
+ where do you make the switch
* Database things
+ Basic crud stuff
+ Mojo::Pg
+ more testing
* REST (-like) interactive interfaces
+ handling routes based on the URL
+ cookies
+ sessions
+ multiple controllers
+ different return types (json, html, etc)
* Writing a simple web service
+ get and post
+ API publishing thingys
* Writing a complex web service
+ put
+ delete
+ other such things
* Chat server (websockets?)
+ shared message queue, etc
* Plugins and the like
* Advanced Rendering tricks
* Misc Advanced topics
* Production Servers
+ deployment
+ hypnotoad
+ proxied behind apache
+ proxied behind nginx
+ cloudflare
+ aws
* Appendices
+ What we didn't cover
----
Similar books:
* Flask Web Development
* https://django-book.readthedocs.io/en/latest/
* https://www.railstutorial.org/book
* https://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-world
@kraih
Copy link

kraih commented Dec 5, 2019

👍 I'm a big fan of this type of tutorial book.

It would probably make sense to include a few more options for the model layer, since most bigger apps that don't require non-blocking database access use DBIx::Class. Or even combine multiple model layers, which is one of the advantages of Mojolicious being model layer agnostic (postgres + redis anyone?).

Perhaps a chapter on Minion? (which i also consider a model) It's becoming one of our biggest selling points, almost every non-trivial web application uses a job queue.

Other topics that regularly come up on IRC that i can think of right now are file uploads (and how to handle them efficiently), using prefork servers with websockets (broadcasting to all websockets via database/pubsub) and how to optimize the built-in web servers for different workloads (--clients 1 and lots of --workers for apps that do a lot of blocking database operations, and the opposite for websocket servers).

@marcusramberg
Copy link

marcusramberg commented Dec 6, 2019

I like it too, specially the part about docker/aws deployment. Might want to focus it on eks/kubernetes to make it more generally applicable across cloud environments.

@kraih
Copy link

kraih commented Dec 6, 2019

@jberger
Copy link

jberger commented Dec 6, 2019

  • Form handling: you probably want to look at the validator, at least mention that its there if not actually explain it in detail. There is also heavier things like JSON::Validator/joi/OpenAPI that can help too.
  • When to switch to full apps? I do it almost immediately, except in the cases of demos and PURE proof of concepts. Hybrid-style full apps are so easy I almost always skip right to that. Sure teach lite, but the switch comes very early for me.
  • I like the heavy focus on testing. I do that in my mojo talks too. Mojo is very test-inspired (if not purely TDD), and showing how easy it is to test a mojo app is often a major selling point (and a thing I miss in most other languages/frameworks).

@christopherraa
Copy link

christopherraa commented Dec 8, 2019

  • Emphasis on full apps would be nice. We almost immediately go to full apps due to simplified structure and easier testing
  • A common question we've had with clients during trainings is how to "properly" extract code into plugins
  • When to use helpers as $c->helper_name() VS $c->app->helper_name()
  • Deploying to hosted k8s is pretty common in books / tutorials these days, but running Docker containers locally is a very good and easy way to demonstrate the concepts. Building an example application with 1) a full application 2) a PostgreSQL server and 3) a minion worker all run through docker-compose would demonstrate a lot of the things that people often need in their applications. docker-compose is also very low-threshold compared to a full k8s-deployment.
  • OpenAPI is still relevant, so it would propably be good to cover that both from the consumer and the provider side of things. Having an application exposing something OpenAPI-enables, and using the OpenAPI-client as part of the tests would perhaps be a good enough demonstration?

Other than that: love the initiative!

@preaction
Copy link

preaction commented Feb 3, 2020

Some ideas for the advanced rendering tricks chapter:

  • include w/ custom stash arguments (or even just inheriting the stash from the parent)
  • extends is massively useful, but it took me quite a bit of playing around to figure out how useful (something a book would be perfect to shortcut)

Another possible idea that might be its own book:

  • Overriding Mojolicious's behavior with_roles: In Mojolicious, nearly every method can be a hook to custom behavior by doing $app->$THING->with_roles( 'My::Role' ). Not that the existing hooks aren't powerful enough (the around dispatch hook can do literally anything)

@alaurie
Copy link

alaurie commented Feb 6, 2020

I think a companion video course along with the book would be a great idea. This is probably biased in the fact that I personally don't find technical books deeply engaging. Usually get part way through and never finish. I think there is a market there and is easier to keep updated and tweak than a published book (unless self publishing). Examples below are well regarded video courses.

Course Examples:
https://courses.miguelgrinberg.com/p/flask-mega-tutorial
https://training.talkpython.fm/
https://realpython.com/courses/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment