how you can personalize a Toto web site web page
Throughout the 7 days between Xmas and New Year’s I ultimately took enough time to redesign and redeploy this site on Heroku making use of Toto, a quite simple Rack site motor. Sorry if I spammed your RSS inbox with duplicate article content.
What helps make Toto amazing is that it incorporates simply enough code to run a very simple site web site… and nothing else. Alexis Sellier’s code is concise and elegant; you may see everything in just one Ruby file: toto.rb. It leaves you a cleanse, blank slate to add just about anything special 토토사이트 or customized you may perhaps will need. Actually, I selected to make use of Toto in lieu of Jekyll, Nesta or other blog engine possibilities only because it appeared like it would be enjoyable to know how it works and customise it.
Here’s 4 suggestions to bear in mind as you work with Toto, based upon my practical experience developing This website:
Use bundler in lieu of a Heroku .gems file
Operate with Shotgun
Use Rack::Rewrite for supporting shortened or out of date URLs
Take some time to know and use Toto’s Riot/RR test suite
Use bundler as opposed to a Heroku .gems file
The ultimate way to start out with Toto would be to Examine the GitHub readme page. Mainly Anything you do is clone the example site template called “Dorothy” similar to this:
$ git clone git://github.com/cloudhead/dorothy.git myblog
$ cd myblog
Now you have a super-basic Rack app identified as “myblog” that you could potentially deploy to Heroku quickly for those who wanted to. It includes a rackup file (config.ru) and also a .gems file that tells Heroku which gems to install:
$ cat .gems
It is possible to see your new blog site site will use builder (to deliver the RSS XML feed), rdiscount (to parse the markdown information) as well as toto gem, that’s the web site motor alone. Nonetheless, before continuing I might just take a couple of minutes so as to add bundler to the application and substitute the .gems file which has a Gemfile. Moreover emotion a little bit extra modern day and just like Rails three, employing Bundler can make it user friendly a tailored Toto gem from the hard disk or your github repo. Listed here’s how to make it happen…
Initial, inside the myblog folder edit config.ru and include the two strains at the best which i’ve highlighted:
# Rack config
use Rack::Static, :urls => [‘/css’, ‘/js’, ‘/pictures’, ‘/favicon.ico’], :root => ‘public’
and many others…
And now exchange the .gems file
$ rm .gems
…with a Gemfile:
gem “toto”, :route => ‘../customized_toto’
Here together with the builder and rdiscount gems, I’ve indicated to bundler that it should use a duplicate of Toto on my regional harddrive inside of a folder referred to as “customized_toto.” At this point you must fork the Toto repo on GitHub and clone it on your machine in the “customized_toto” folder one example is:
$ cd ..
$ git clone [email protected]:yourname/toto.git customized_toto
And finally set up the bundle for your personal website application:
$ cd myblog
$ bundle install
Fetching source index for http://rubygems.org/
Using builder (3.0.0)
Applying rack (one.2.1)
Utilizing rdiscount (1.six.five)
Working with toto (0.four.9) from supply at /People/pat/applications/customized_toto
Using bundler (one.0.0)
Your bundle is finish! Use `bundle show [gemname]` to determine exactly where a bundled gem is put in.
If you’re willing to thrust your web site to Heroku, you will just replace the “:route =>” location along with your github repo URL, utilizing the “:git” solution. As an example, right here’s the Gemfile from this site’s Heroku application:
gem “toto”, :git => ‘https://github.com/patshaughnessy/toto.git’
Heroku now supports bundler, and will quickly run bundle set up within the server Once you push your blog website there. Devoid of bundler, using diverse variations with the Toto gem can be far more of a hassle.
Operate with Shotgun
Commonly you’ll startup your Toto blog site internet site like every other rack application, With all the “rackup” command:
$ cd myblog
Rackup will try to look for config.ru in The existing Listing, and start your application on port 9292. Even so, the trouble with this is always that the application code is cached involving HTTP requests, just like how a Rails application will work in output. In the event you’re preparing on modifying the Toto site motor code and not simply your blog’s information, You then would have to quit and restart the server every time you manufactured a code improve.
For enhancement, it’s a lot more convenient to employ Shotgun instead. This is a Model of your rackup command that will create a wholly new approach For each HTTP request. What What this means is When you’re working with the Toto code is that you can make any sort of code modify you’d like and just refresh your browser to view it function. You don’t want to worry about everything staying cached.
You simply have to have to install it, and run “shotgun” rather than “rackup:”
$ gem set up shotgun
$ cd myblog
Now you’ll obtain your website at http://locahost:9393 as opposed to port 9292.
Use Rack::Rewrite for supporting shortened or obsolete URLs
As Dmitry Fadeyev identified in his handy post Getting going With Toto, a Very small WordPress Killer, if you’re migrating from another blog motor the Rack-Rewrite gem by John Trupiano is a terrific way to redirect URL designs from the outdated website into what Toto expects. You can even utilize it like me to shorten URLs for some posts. Rack-Rewrite is a handy bit of rack middleware that applies Apache rewrite procedures to HTTP requests coming in the Rack stack. What this means is it can be employed to redirect or modify URL styles before they strike the Toto code, and stay away from the need to transform Toto in the slightest degree for this goal.
With bundler it’s very simple to incorporate Rack-Rewrite… all you’ll want to do is increase a line towards your Gemfile like this: