If you need a good way to secure your Django admin site (e.g., http://example.com/admin/), this is it.
Reference: https://gist.github.com/mtigas/952344
| defmodule Brando.Form.UserForm do | |
| use Brando.Form | |
| import Brando.Router.Helpers | |
| def get_status_choices do | |
| [[value: "0", text: "Choice 1"], | |
| [value: "1", text: "Choice 2"]] | |
| end | |
| form "user", [method: "POST", action: admin_user_path(:create)] do |
| # increase the stacktrace depth | |
| :erlang.system_flag(backtrace_depth, n) |
| <%= render MyApp.SomeView, "sometemplate.html", user: @user %> | |
| # all parent assigns | |
| <%= render MyApp.SomeView, "sometemplate.html", assigns %> |
| # in template | |
| <%= next_page_path({:user_path, [:index]}, @current_page, @conn.params %> | |
| # in view | |
| def next_page_path({cur_path, helper_args}, cur_page, params \\ []) do | |
| params = Dict.merge(params, %{"page" => cur_page + 1}) | |
| apply(MyApp.Router.Helpers, cur_path, helper_args ++ [params]) | |
| end |
| for locale <- ["en", "fr"] do ... get "/#{I18n.t(locale, "routes.users")" |
| iex(14)> :dbg.tracer | |
| {:ok, #PID<0.109.0>} | |
| iex(15)> :dbg.p :all, :c | |
| {:ok, [{:matched, :nonode@nohost, 39}]} | |
| iex(16)> :dbg.tpl Z, :x | |
| {:ok, [{:matched, :nonode@nohost, 4}, {:saved, :x}]} | |
| iex(17)> struct(Z, Map.from_struct(%V{}) | |
| ...(17)> ) |
| # install libpng15 | |
| # ---------------- | |
| ./configure --prefix=/usr/local/libpng | |
| make check | |
| sudo make install | |
| make check | |
| # | |
| sudo updatedb |
If you need a good way to secure your Django admin site (e.g., http://example.com/admin/), this is it.
Reference: https://gist.github.com/mtigas/952344
| $less-column-width: 68px; | |
| $less-gutter-width: 24px; | |
| @function column-width($columns) { | |
| @return ($less-column-width * $columns) + ($less-gutter-width * ($columns - 1)); | |
| } | |
| @function grid-padding-px($columns) { | |
| @if $columns == 10 { | |
| @return 48px; |