Split Padrino Controllers

Some things are bigger the better. But some, when they are big, are truly ugly! Code makes the top of that list. I recently opened a Padrino class with 2900+ lines of pure spaghetti. It was traumatic to touch that file that had countless number of actions in it.

Making an admin section? Wondering how to avoid writing every thing in app/controllers/admin.rb? Well you are of luck and the approach is really simple.

Xygen is not its real name.

# file: app/controllers/admin/products.rb
class Xygen::App.controllers :admin do
  layout :admin

  get '/products' do
    @products = Product.all
    render 'admin/products/index'
  end

  # get '/products/:id' do
  # end
  # and so on...
end

Now that you are splitting code in to files, you might wonder where to add common code.

There are few places you can add them to.

  1. Helpers (my preferred)
  2. app.rb (lets keep that slim too, shall we?)
# file: app/helpers/admin.rb
class Xygen::App.helpers do
  def authenticate
    # your foo doo
  end
end

And finally use it in your code…

# file app/controllers/admin/products.rb
class Xygen::App.controllers :admin do
  before { authenticate }
  # rest of the code ...
end

TextbookValet Gets Highrise Integration

Highrise is a CRM ideal for small businesses. While we at TextbookValet are not entirely small, and have built required CRM features to our app, we used Highrise integrations to reach out to multiple services used in the hiring processes.

We worked with 5 services (possibly more that I am not aware) that integrated with Highrise. They will make contacts with necessary information set as custom fields. Then our web app will connect to Highrise through the API and synchronize with it.

This way we only need to integrate one service, saving us time, and money.

Link: Highrise API Gem

Introduction

The Strange Case of Dr. Jekyll and Mr. Hyde tells the story of a lawyer investigating the connection of two persons, Dr. Henry Jekyll and Mr. Edward Hyde. Chief among the novel’s supporting cast is a man by the name of Mr. Poole, Dr. Jekyll’s loyal butler.


Poole is the butler for Jekyll, the static site generator. It’s designed and developed by @mdo to provide a clear and concise foundational setup for any Jekyll site. It does so by furnishing a full vanilla Jekyll install with example layouts, pages, posts, and styles.

There are currently three themes built on Poole:

Learn more and contribute on GitHub.

What’s included

Poole is a streamlined Jekyll site designed and built as a foundation for building more meaningful themes. Poole, and every theme built on it like this one, includes the following:

  • Complete Jekyll setup included (layouts, config, 404, RSS feed, posts, and example page)
  • Mobile friendly design and development
  • Easily scalable text and component sizing with rem units in the CSS
  • Support for a wide gamut of HTML elements
  • Related posts (time-based, because Jekyll) below each post
  • Syntax highlighting, courtesy Jekyll’s built-in support for Rouge

Additional features are available in individual themes.

Browser support

Poole and its themes are by preference a forward-thinking project. In addition to the latest versions of Chrome, Safari (mobile and desktop), and Firefox, it is only compatible with Internet Explorer 9 and above.

Download

These themes are developed on and hosted with GitHub. Head to the GitHub repository for downloads, bug reports, and features requests.

Thanks!

What's Jekyll?

Jekyll is a static site generator, an open-source tool for creating simple yet powerful websites of all shapes and sizes. From the project’s readme:

Jekyll is a simple, blog aware, static site generator. It takes a template directory […] and spits out a complete, static website suitable for serving with Apache or your favorite web server. This is also the engine behind GitHub Pages, which you can use to host your project’s page or blog right here from GitHub.

It’s an immensely useful tool. Find out more by visiting the project on GitHub.

Introducing Hyde

Hyde is a brazen two-column Jekyll theme that pairs a prominent sidebar with uncomplicated content. It’s based on Poole, the Jekyll butler.

Built on Poole

Poole is the Jekyll Butler, serving as an upstanding and effective foundation for Jekyll themes by @mdo. Poole, and every theme built on it (like Hyde here) includes the following:

  • Complete Jekyll setup included (layouts, config, 404, RSS feed, posts, and example page)
  • Mobile friendly design and development
  • Easily scalable text and component sizing with rem units in the CSS
  • Support for a wide gamut of HTML elements
  • Related posts (time-based, because Jekyll) below each post
  • Syntax highlighting, courtesy Pygments (the Python-based code snippet highlighter)

Hyde features

In addition to the features of Poole, Hyde adds the following:

  • Sidebar includes support for textual modules and a dynamically generated navigation with active link support
  • Two orientations for content and sidebar, default (left sidebar) and reverse (right sidebar), available via <body> classes
  • Eight optional color schemes, available via <body> classes

Head to the readme to learn more.

Browser support

Hyde is by preference a forward-thinking project. In addition to the latest versions of Chrome, Safari (mobile and desktop), and Firefox, it is only compatible with Internet Explorer 9 and above.

Download

Hyde is developed on and hosted with GitHub. Head to the GitHub repository for downloads, bug reports, and features requests.

Thanks!