Skip to content

brandocms/brando

Repository files navigation

A helping hand.

*EXPERIMENTAL, NOT RECOMMENDED TO USE BEFORE IN MORE STABLE FORM!*

Install

Start by creating a new Phoenix project:

$ mix phx.new my_project

Run the install script:

$ wget https://raw.githubusercontent.com/brandocms/brando/master/install.sh && chmod +x install.sh && ./install.sh

Go through config/brando.exs.

To use Brando's error views, add to your Endpoint's config (in prod.exs):

config :my_app, MyApp.Endpoint,
  render_errors: [
    formats: [html: Brando.ErrorHTML, json: Brando.ErrorJSON], layout: false
  ],

Remember to switch out your ports and configure SSL in etc/nginx/prod.conf

Dependencies

  • sharp/sharp-cli for image processing. Installation instructions: #183
  • gifsicle for GIF resizing.

I18n

Brando uses Gettext for i18n.

To extract your frontend translations:

$ mix gettext.extract

Create your frontend translation directories: (for norwegian)

$ mkdir -p priv/gettext/frontend/no/LC_MESSAGES

Merge frontend translations

$ mix gettext.merge priv/gettext/frontend --plural-forms=2

Generators

Generate blueprint

$ mix brando.gen.blueprint

Generate templates:

$ mix brando.gen

Serve static from DO Spaces

Setup Endpoint for prod.exs

config :my_app, hmr: false
config :my_app, MyAppWeb.Endpoint,
  static_url: [
    scheme: "https",
    host: "cdn.univers.agency",
    path: "/my_app/static",
    port: 443
  ]

config :ex_aws, :s3, %{
  access_key_id: System.get_env("AWS_ACCESS_KEY_ID"),
  secret_access_key: System.get_env("AWS_SECRET_ACCESS_KEY"),
  scheme: "https://",
  host: %{"fra1" => "SPACES_NAME.fra1.digitaloceanspaces.com"},
  region: "fra1"
}

Add to your frontend package.json

"build": "webpack --mode=production --config webpack.prod.js",
"build:cdn": "BRANDO_CDN=<%= application_name %> NODE_ENV=production webpack --mode=production --config ./webpack.config.prod.js",

Make sure you build frontend with:

RUN yarn run build.cdn

Add to Dockerfile build:

$ mix brando.static.deploy