@grych grych released this Nov 28, 2018 · 1 commit to master since this release

Assets 2

Drab is now blessed and tested to work with Pheonix 1.4. Plus bugfixes.

@grych grych released this Sep 8, 2018 · 18 commits to master since this release

Assets 2

This is a maintenance release: few bugfixes.

@grych grych released this Aug 10, 2018 · 31 commits to master since this release

Assets 2

This is a slow evolution release, containing a number of bug fixes and a few new features:

  • Cookies function in Drab.Browser
iex> set_cookie(socket, "mycookie", "value", max_age: 10)
{:ok, "mycookie=value; expires=Thu, 19 Jul 2018 19:47:09 GMT"}

iex> Drab.Browser.cookies(socket, decoder: Drab.Coder.Cipher)
{:ok, %{"other" => 42, "mycookie" => "value"}}
  • Drab.{Live, Core, Element, Modal} functions accept %Phoenix.HTML.Safe{}

That means you don't need to call safe_to_string/1 anymore, just pass the safe:

html = ~E"<strong><%= nick %>:</strong> <%= message %><br>"
broadcast_insert socket, "#chat", :beforeend, html
  • Tested with Elixir 1.7

Drab is now blessed to work with Elixir 1.7 and OTP 21.

@grych grych released this Jul 15, 2018 · 67 commits to master since this release

Assets 2

Drab.Modal is not dependent on Drab.Query anymore, and does not require jQuery to run! You
may now use it out of the box, with standard Phoenix installation. Works with both Bootstrap 3
and 4, while Bootstrap 3 is used by default. In case you want to use Bootstrap 4, configure it with:

config :drab, :modal_css, :boostrap4

Drab.Modal is now loaded by default, as it became the part of Standard Drab Modules.

Also changed the Drab store storage, now it is encrypted, not only signed.

Templates for modal and buttons have been changed!

If you are already using the custom templates for modal of for the button, please read the documentation and update them.

@grych grych released this Jun 29, 2018 · 80 commits to master since this release

Assets 2

This release finally introduces the final API. There is no intention to change it, unless very
significant errors are found.

If you are using Drab already, prepare for the changes in the configuration and also in the code.

Drab.Live API changed

As described in #127, API has changed. The most painful change is Drab.Live.peek, as it now
returns {:ok, value} or {:error, why}. Raising Drab.Live.peek is for convinience.

Drab.Live.poke returns tuple now as well, to catch update errors or disconnections.

Redesigned Drab.Config

Since this version, Drab is no longer configured globally. This means that you may use it in the
multiple endpoints environments.
This requires configuration API change. Most of the Drab options are now located under
the endpoint module:

config :drab, MyAppWeb.Endpoint,
  otp_app: :my_app_web,

The endpoint and application name are mandatory.

However, there are still few global options, like :enable_live_scripts. Please read
Drab.Config documentation
for more information.

Do You Want to Know More?

More API changes

All functions returning {:timeout, description} now return just {:error, :timeout}.

Undeclared handler or shared commander raises

All handlers must now be strictly declared by using Drab.Commander.defhandler or
Drab.Commander.public macro.

defhandler my_handler(socket, payload), do: ..


public :my_handler
def my_handler(socket, payload), do: ...

The same is with shared commanders, if you want to use it, declare it with Drab.Controller:

use Drab.Controller, commanders: [My.Shared.Commander]

Hard depreciations of various functions

  • Drab.Client.js/2
  • Drab.run_handler()
  • Drab.Browser.console!/2
  • Drab.Browser.redirect_to!/2
  • Drab.Core.broadcast_js!/2

drab-event and drab-handler combination no longer exists

The existing syntax drab-event and drab-handler is removed. Please use the new syntax of:

<tag drab="event:handler">
<input drab="focus:input_focus blur:input_blur"
<input drab-focus="input_focus" drab-blur="input_blur">

Do You Want to Know More?

Updating from <= v0.8.3



config :drab, main_phoenix_app: :my_app_web, endpoint: MyAppWeb.Endpoint


config :drab, MyAppWeb.Endpoint, otp_app: :my_app_web

Most of the configuration options now must be placed under the endpoint. Please read
Drab.Config documentation for more info.

@grych grych released this Jun 22, 2018 · 97 commits to master since this release

Assets 2

This version brings two useful features: presence and ability to subscribe to topics in the runtime.

Upgrading from =< 0.8.2

Please ensure you have set :main_phoenix_app in your config.exs. The way how Drab is searching
for the Phoenix app it is working on, has been changed.

Subscribe and unsubscribe from external topics in a runtime

Finally, you are not limited to the compile-time topic you’ve set with broadcasting/1 macro in the
commander. Now you can subscribe/2 to the external topic, receiving broadcasts sent to it.

subscribe(socket, same_action(MyApp.MyController, :index))
subscribe(socket, same_topic("user_#{user_id}"))


Conveniences for Phoenix.Presence
If configured (it is disabled by default), tracks the user presence on the topic. The following
example shows the number of connected users, live:

defmodule MyAppWeb.MyCommander
  use Drab.Commander

  broadcasting "global"
  onconnect :connected
  ondisconnect :disconnected

  def connected(socket) do
    broadcast_html socket, "#number_of_users", Drab.Presence.count_users(socket)

  def disconnected(_store, _session) do
    topic = same_topic("global")
    broadcast_html topic, "#number_of_users", Drab.Presence.count_users(topic)

By default, presence map key is set as a browser UUID (which is shamelessly stored in the local
store in the browser), but it may be also any session value. This may be useful, if you have the
user_id already in the session, just configure it:

config :drab, :presence, id: :user_id

Updated enable/disable when processing behaviour

After launching an event from the page, the control (button) is disable until processing stops.
Now it is even better, as it recognizes previously disabled controls (#146).

@grych grych released this Jun 12, 2018 · 125 commits to master since this release

Assets 2

This version is a preparation for v0.9.0, which is going to bring API changes, as described in #127.

  • new functions in Drab.Element (#134, #135)
  • new Drab.Coder for encoding terms to string (#137)
  • new js_socket_constructor config (#133), useful when using Drab with Webpack
  • all assigns are now peekable (#126)
  • broadcast_poke now gets subject, not only socket (under some limitations) (#141)
  • preserve csrf token if poke updates the form (fix for #130)

@grych grych released this May 18, 2018 · 168 commits to master since this release

Assets 2

Very important role of Drab is to encourage beginners to try out Elixir |> Phoenix |> Drab. The
goal is to have an environment, which is less scary than others, like ruby.rails.ajax. This
is why all the configuration stuff should be minimized (but with options for power users).

mix drab.install

Bug Fixes

Again, Drab.Live engine has been redesigned to solve existing and future issues.

@grych grych released this May 9, 2018 · 189 commits to master since this release

Assets 2

Potentially breaking release!

Drab.Live engine has been redesigned again. No more stupid DETS cache anymore. Drab engine now creates modules for each template, and stores metadata compiled there.

Elixir version

Bumped to 1.6, because of the changes in the EEx Engine

Migration from 0.7.7

rm priv/drab.live.cache
mix clean

Bug fixes

Many. See closed issues!

@grych grych released this Apr 28, 2018 · 221 commits to master since this release

Assets 2

Potentially breaking release!

As a preparation to 0.8.0, this release contains fundamental change in Drab.Live behaviour. It
removes all the engine limitations, and makes a big change on how it treats @conn assign.

Please report any found issues with this release.

API Changes

The @conn case

Because sometimes it is huge, @conn is treated in the special way - it is trimmed to contain only
essential fields. By default it is :private => :phoenix_endpoint, but you may configure it.

config :drab, :live_conn_pass_through, %{
  assigns: %{
    users: true
  private: %{
    phoenix_endpoint: true

See Drab.Live documentation for more details on this case.

:templates_path config must be under priv/

If you are using :templates_path config, and your templates are not under the priv/ directory,
you'll have to move them. Solved #105.