Code Monkey home page Code Monkey logo

padrino_saas_website's Introduction

Padrino SasS Demo

This demo application shows how Padrino can be used to divide an application into multiple small applications all running on the one server

The advantage of structuring an application this way is that it results in a very clear separation of concerns between the different aspects of your application. As an example this demo contains 3 small applications, 1 for the sales site, 1 for the core application and 1 for user login and logout.

Here's a description of each of the separate applcations.

Padrino SaaS Website

This is the base application and stores all the shared assets and resources used throughout the entire application. Once deployed this will most probably contain your sales site or whatever content you want display by default on your domain. The advantage of having a small application behind your sales site is that you can build a lightweight CMS or perform some A/B testing which you couldn't do with a purely static website.

Here we also define which sub applications we want to mount and where they should mounted to. Inside config/apps.rb we see the following code which mounts all the applications.

Padrino.mount("PadrinoSaasWebsite").to('/')
Padrino.mount("PadrinoSaasApplication", app_file: Padrino.root("padrino_saas_application/app/app.rb")).to('/app')
Padrino.mount("PadrinoSaasUsers", app_file: Padrino.root("padrino_saas_users/app/app.rb")).to('/users')

The default layout that's shared across all applications is also within this application and can be found in app/views/layouts/website.haml. Finally there are shared assets such as stylesheets which are in app/stylesheets.

Padrino SaaS Application

At the center of your SaaS there will generally be a core application which is where your users will actually use your product. If you where building Gmail it would be the Inbox page, for twitter it would the timeline.

This application has the option to use layouts and assets from the base Website application. At the moment you need to do the following in order to use the layout from the parent application

get '/' do
  render :index, layout: :"../../../../app/views/layouts/website"
end

As you can see it's not an ideal way to reference the parent layout but I'm led to believe this will be tidied up in the not too distant future.

Padrino SaaS Users

Finally to demonstrate sharing sessions across the application I've created a small users application that allows you to login and logout. You will be able to see the global navigation change to reflect your current state.

padrino_saas_website's People

Stargazers

Jason Lee Ertle avatar

Watchers

Jason Lee Ertle avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.