adds bkmark.me header to app layout

adds bkmark.me header to app layout

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Bkmark Me, Phoenix!</title>
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">

    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">

    </button>
    Bkmark.me

Bookmarks

Users

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

<%= @inner %>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Bkmark Me, Phoenix!</title>
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">

Bookmarks

Users

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

      <%= @inner %>


Change text

Change text

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Online Experiments System for Economic Education">
    <meta name="author" content="Ryohei HAYASHI">

    <%= if assigns[:title] do %>
      <title>XEE.JP - <%= @title %> -</title>
    <% else %>
      <title>XEE.JP</title>
    <% end %>

    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
    <link rel="shortcut icon" href="<%= static_path(@conn, "/favicon.ico") %>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.1.0/introjs.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<a href="<%= host_path(@conn, :index) %>">実験管理画面

<%= link "ログアウト", to: session_path(@conn, :delete) %>

            XEE.JP
            <%= if assigns[:title] do %>
              <%= @title %>
            <%= end %>

              <%= if logged_in?(@conn) do %>

<%= current_user(@conn).name %>

              <% else %>

<%= link "教師用ページ", to: registration_path(@conn, :new) %>

<%= link "ログイン", to: session_path(@conn, :new) %>

              <% end %>

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

<%= render @view_module, @view_template, assigns %>

© 2015 Ryohei HAYASHI All Rights Reserved.

Powered by <a href="<%= page_path(@conn, :about) %>">Xee System.

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="Online Experiments System for Economic Education">
    <meta name="author" content="Ryohei HAYASHI">

    <%= if assigns[:title] do %>
      <title>XEE.JP - <%= @title %> -</title>
    <% else %>
      <title>XEE.JP</title>
    <% end %>

    <link rel="stylesheet" href="<%= static_path(@conn, "/css/app.css") %>">
    <link rel="shortcut icon" href="<%= static_path(@conn, "/favicon.ico") %>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.6/css/materialize.min.css">

    <link href="https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.1.0/introjs.min.css" rel="stylesheet" type="text/css">
    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<a href="<%= host_path(@conn, :index) %>">実験管理画面

<%= link "ログアウト", to: session_path(@conn, :delete) %>

            XEE.JP
            <%= if assigns[:title] do %>
              <%= @title %>
            <%= end %>

              <%= if logged_in?(@conn) do %>

<%= current_user(@conn).name %>

              <% else %>

<%= link "新規登録", to: registration_path(@conn, :new) %>

<%= link "ログイン", to: session_path(@conn, :new) %>

              <% end %>

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

<%= render @view_module, @view_template, assigns %>

© 2015 Ryohei HAYASHI All Rights Reserved.

Powered by <a href="<%= page_path(@conn, :about) %>">Xee System.


Preview iframe height fix

Preview iframe height fix

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%= render_existing(@view_module, "meta." <> @view_template, assigns) || render(Ap.LayoutView, "meta.html", assigns) %>

    <style media="screen">
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }

    header {
      height: 50px;
      background: #2f2f2f;
      color: #ccc;
      line-height: 48px;
      font-size: 16px;
      font-weight: bold;
      font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
      text-align: center;
      overflow: hidden;
      position: relative;
    }

    header .back {
      position: absolute;
      display: inline-block;
      color: #eee;
      top: 0;
      left: 20px;
      text-decoration: none;
    }

    header .title {
      margin: 0;
      padding: 0;
      display: inline-block;
    }

    @media(max-width: 600px) {
      header .title {
        display: none;
      }
    }

    header a.btn {
      text-decoration: none;
      color: #ffffff;
      display: inline-block;
      padding: 6px 16px;
      font-size: 12px;
      letter-spacing: 0.3px;
      text-transform: uppercase;
      font-weight: bold;
      background: #0066DE;
      border-radius: 2px;
      line-height: 1.2;
      position: relative;
      top: -2px;
      left: 10px;
    }

    #wrapper {
      height: 500px;
      height: calc(100vh - 50px);
    }
    </style>

  </head>

  <body>

    <%= render @view_module, @view_template, assigns %>

    <script type="text/javascript">

    function ready(fn) {
      if (document.readyState != 'loading'){
        fn();
      } else {
        document.addEventListener('DOMContentLoaded', fn);
      }
    }

    ready(function() {
      var header = document.getElementById("header");
      var wrapper = document.getElementById("wrapper");

      function setHeight() {
        wrapper.style.height = window.outerHeight - header.offsetHeight + "px";
      }

      if (window.addEventListener) {
        window.addEventListener("resize", setHeight);
      }

      setHeight();

    })

    </script>
  </body>
</html>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%= render_existing(@view_module, "meta." <> @view_template, assigns) || render(Ap.LayoutView, "meta.html", assigns) %>

    <style media="screen">
    html, body {
      height: 100%;
      margin: 0;
      padding: 0;
      overflow: hidden;
    }

    header {
      height: 50px;
      background: #2f2f2f;
      color: #ccc;
      line-height: 48px;
      font-size: 16px;
      font-weight: bold;
      font-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
      text-align: center;
      overflow: hidden;
      position: relative;
    }

    header .back {
      position: absolute;
      display: inline-block;
      color: #eee;
      top: 0;
      left: 20px;
      text-decoration: none;
    }

    header .title {
      margin: 0;
      padding: 0;
      display: inline-block;
    }

    @media(max-width: 600px) {
      header .title {
        display: none;
      }
    }

    header a.btn {
      text-decoration: none;
      color: #ffffff;
      display: inline-block;
      padding: 6px 16px;
      font-size: 12px;
      letter-spacing: 0.3px;
      text-transform: uppercase;
      font-weight: bold;
      background: #0066DE;
      border-radius: 2px;
      line-height: 1.2;
      position: relative;
      top: -2px;
      left: 10px;
    }
    </style>

  </head>

  <body>

    <%= render @view_module, @view_template, assigns %>

    <script type="text/javascript">

    function ready(fn) {
      if (document.readyState != 'loading'){
        fn();
      } else {
        document.addEventListener('DOMContentLoaded', fn);
      }
    }

    ready(function() {
      var header = document.getElementById("header");
      var wrapper = document.getElementById("wrapper");

      function setHeight() {
        wrapper.style.height = window.outerHeight - header.offsetHeight + "px";
      }

      if (window.addEventListener) {
        window.addEventListener("resize", setHeight);
      }

      setHeight();

    })

    </script>
  </body>
</html>


Remove birthdate field prompts for now, as they break empty form submission

<%= inputs_for @form, :participant, fn p -> %>

      <%= label p, :given_name, gettext("First name") %>
      <%= text_input p, :given_name, class: "form-control" %>
      <%= error_tag p, :given_name %>

      <%= label p, :family_name, gettext("Last name") %>
      <%= text_input p, :family_name, class: "form-control" %>
      <%= error_tag p, :family_name %>

      <%= label p, :birthdate, gettext("Birthdate") %>
      <%= date_select p, :birthdate, builder: fn b -> %>

          <%= b.(:day, [class: "form-control"]) %>

          <%= b.(:month, [class: "form-control"]) %>

          <%= b.(:year, [
            class: "form-control",
            options: birthyear_options(@season)
            ]) %>

      <% end %>
      <%= error_tag p, :birthdate %>

      <%= label @form, :participant_role, gettext("Role") %>
      <%= select @form, :participant_role, role_options(),
        prompt: gettext("Please choose"), class: "form-control"
        %>
      <%= error_tag @form, :participant_role %>

      <%= label @form, :instrument, gettext("Instrument") %>
      <%= select @form, :instrument, instrument_options(),
        prompt: gettext("Please choose"), class: "form-control"
        %>
      <%= error_tag @form, :instrument %>

      <%= label p, :phone, gettext("Phone") %>
      <%= text_input p, :phone, class: "form-control" %>
      <%= error_tag p, :phone %>

      <%= label p, :email, gettext("Email") %>
      <%= text_input p, :email, class: "form-control" %>
      <%= error_tag p, :email %>

<% end %>

<%= inputs_for @form, :participant, fn p -> %>

      <%= label p, :given_name, gettext("First name") %>
      <%= text_input p, :given_name, class: "form-control" %>
      <%= error_tag p, :given_name %>

      <%= label p, :family_name, gettext("Last name") %>
      <%= text_input p, :family_name, class: "form-control" %>
      <%= error_tag p, :family_name %>

      <%= label p, :birthdate, gettext("Birthdate") %>
      <%= date_select p, :birthdate, builder: fn b -> %>

          <%= b.(:day, [class: "form-control", prompt: gettext("Day")]) %>

          <%= b.(:month, [class: "form-control", prompt: gettext("Month")]) %>

          <%= b.(:year, [
            class: "form-control",
            options: birthyear_options(@season),
            prompt: gettext("Year")
            ]) %>

      <% end %>
      <%= error_tag p, :birthdate %>

      <%= label @form, :participant_role, gettext("Role") %>
      <%= select @form, :participant_role, role_options(),
        prompt: gettext("Please choose"), class: "form-control"
        %>
      <%= error_tag @form, :participant_role %>

      <%= label @form, :instrument, gettext("Instrument") %>
      <%= select @form, :instrument, instrument_options(),
        prompt: gettext("Please choose"), class: "form-control"
        %>
      <%= error_tag @form, :instrument %>

      <%= label p, :phone, gettext("Phone") %>
      <%= text_input p, :phone, class: "form-control" %>
      <%= error_tag p, :phone %>

      <%= label p, :email, gettext("Email") %>
      <%= text_input p, :email, class: "form-control" %>
      <%= error_tag p, :email %>

<% end %>


Adding link to notification messages from articles

Manage your preferences

      <%= link "back to \"How Post Works\"", to: page_path(@conn, :index) %>

Manage your preferences

        <%= form_for team_changeset(@current_team), preference_path(@conn, :update), fn form -> %>

View Count Spike

            Notify me when there is an increase of at least <%= text_input form, :min_view_count_increase, class: "preferences__input", autofocus: "true" %> views,
            and there is pageview increase of <%= text_input form, :view_count_threshold, class: "preferences__input" %>% or more.

Source Spike

            Notify me when there is difference of at least <%= text_input form, :min_source_count_increase, class: "preferences__input", autofocus: "true" %> views,
            and more than <%= text_input form, :source_count_threshold, class: "preferences__input" %>% of views coming from one particular site.

            <%= submit "Submit" %>

        <% end %>

Customise notification messages

You can customise your notification messages <%= link "here", to: notification_message_path(@conn, :index) %>

Your registered articles

        <%= if Enum.any?(@articles) do %>

              <%= for article <- @articles do %>

                  <%= link article.url, to: article_path(@conn, :show, article), class: "articles__article--url" %>

                    <%= link "Edit", to: article_path(@conn, :edit, article), class: "btn btn-default btn-xs" %>
                    <%= link "Delete", to: article_path(@conn, :delete, article), method: :delete, data: [confirm: "Are you sure?"] %>

              <% end %>

        <% else %>

[You haven't added any articles yet - once you add some they'll show up here]

        <% end %>

      <%= render EspiDni.SharedView, "feedback_link.html" %>

Manage your preferences

      <%= link "back to \"How Post Works\"", to: page_path(@conn, :index) %>

Manage your preferences

        <%= form_for team_changeset(@current_team), preference_path(@conn, :update), fn form -> %>

View Count Spike

            Notify me when there is an increase of at least <%= text_input form, :min_view_count_increase, class: "preferences__input", autofocus: "true" %> views,
            and there is pageview increase of <%= text_input form, :view_count_threshold, class: "preferences__input" %>% or more.

Source Spike

            Notify me when there is difference of at least <%= text_input form, :min_source_count_increase, class: "preferences__input", autofocus: "true" %> views,
            and more than <%= text_input form, :source_count_threshold, class: "preferences__input" %>% of views coming from one particular site.

            <%= submit "Submit" %>

        <% end %>

Your registered articles

        <%= if Enum.any?(@articles) do %>

              <%= for article <- @articles do %>

                  <%= link article.url, to: article_path(@conn, :show, article), class: "articles__article--url" %>

                    <%= link "Edit", to: article_path(@conn, :edit, article), class: "btn btn-default btn-xs" %>
                    <%= link "Delete", to: article_path(@conn, :delete, article), method: :delete, data: [confirm: "Are you sure?"] %>

              <% end %>

        <% else %>

[You haven't added any articles yet - once you add some they'll show up here]

        <% end %>

      <%= render EspiDni.SharedView, "feedback_link.html" %>


Switching to GetSiteControl

Switching to GetSiteControl

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <%= render_existing(@view_module, "meta." <> @view_template, assigns) || render(Ap.LayoutView, "meta.html", assigns) %>

    <link rel="dns-prefetch" href="//res.cloudinary.com">

    <%= render Ap.LayoutView, "common_social_meta.html" %>
    <%= render_existing(@view_module, "social_meta." <> @view_template, assigns) || render(Ap.LayoutView, "social_meta.html", assigns) %>

    <link rel="icon" href="/favicon.ico" />
    <link rel="icon" href="/images/favicon.png" sizes="16x16" type="image/png">

    <%= if Mix.env == :prod do %>

    <% end %>

    <link rel="stylesheet" href="<%= static_path(@conn, "/css/frontend.css") %>">

    <meta name="msvalidate.01" content="3F3F0DA3D9FF8AE3DA64D767717C782B" />

    <%= render Ap.SharedView, "header.html", conn: @conn, product_categories: @product_categories %>

          <%= show_flash(@conn) %>
          <%= render @view_module, @view_template, assigns %>

    <%= render Ap.SharedView, "footer.html", conn: @conn %>


Delete disableVisibilityChange

Delete disableVisibilityChange

Apparently not needed anymore

<script src="//cdn.jsdelivr.net/phaser-ce/2.7.3/phaser.min.js"></script>

<script type="text/javascript">

window.onload = function() {

    var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

    var player
    var cursors
    var player_id
    var player_id_int

    var enemies

    var other_players = []
    var world_state = {}

    function preload () {

        game.load.image('sheep_1', 'images/sheep_1.png');

    }

    function create () {

        enemies = game.add.group()

        player = game.add.sprite(game.world.centerX, game.world.centerY, 'sheep_1');
        player.anchor.setTo(0.5, 0.5);

        cursors = game.input.keyboard.createCursorKeys();
        player_id_int = Math.floor(Math.random() * 1000)
        player_id = player_id_int.toString()

        channel.push("im_new_here", { player: player_id , position: { x: player.x, y: player.y }})

    }

    function update () {

        if (cursors.left.isDown) {
            player.x -= 4;
        }
        else if (cursors.right.isDown) {
            player.x += 4;
        }

        if (cursors.up.isDown) {
            player.y -= 4;
        }
        else if (cursors.down.isDown) {
           player.y += 4;
        }

        other_players.forEach(function(other_player) {
          var other_player_id = parseInt(other_player.player_id);

          if (other_player_id in world_state) {
            other_player.game_object.x = world_state[other_player_id].x
            other_player.game_object.y = world_state[other_player_id].y
          }
        })

        if (player_id_int in world_state) {
          if (world_state[player_id_int].x != player.x ||
                  world_state[player_id_int].y != player.y ) {
            channel.push("new_position", { player: player_id, position: { x: player.x, y: player.y }})
          }
        }
    }

    channel.on("update_world", payload => {

      world_state = payload

    })

    channel.on("new_player_joined", payload => {

      var other_player_id = payload.player_id
      var position = payload.position

      var new_player = game.add.sprite(position.x, position.y, 'sheep_1')
      new_player.anchor.setTo(0.5, 0.5)

      other_players.push({player_id: other_player_id, game_object: new_player})

    })

    channel.on("hello_world", payload => {

      Object.keys(payload).forEach(function(key) {
        if (key == player_id_int) { return }

        var new_player = game.add.sprite(payload[key].x, payload[key].y, 'sheep_1')
        new_player.anchor.setTo(0.5, 0.5);

        enemies.add(new_player)

        other_players.push({player_id: key, game_object: new_player})
      })

    })

};

</script>

<script src="//cdn.jsdelivr.net/phaser-ce/2.7.3/phaser.min.js"></script>

<script type="text/javascript">

window.onload = function() {

    var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });

    var player
    var cursors
    var player_id
    var player_id_int

    var enemies

    var other_players = []
    var world_state = {}

    function preload () {

        game.load.image('sheep_1', 'images/sheep_1.png');

    }

    function create () {

        game.stage.disableVisibilityChange = true;

        enemies = game.add.group()

        player = game.add.sprite(game.world.centerX, game.world.centerY, 'sheep_1');
        player.anchor.setTo(0.5, 0.5);

        cursors = game.input.keyboard.createCursorKeys();
        player_id_int = Math.floor(Math.random() * 1000)
        player_id = player_id_int.toString()

        channel.push("im_new_here", { player: player_id , position: { x: player.x, y: player.y }})

    }

    function update () {

        if (cursors.left.isDown) {
            player.x -= 4;
        }
        else if (cursors.right.isDown) {
            player.x += 4;
        }

        if (cursors.up.isDown) {
            player.y -= 4;
        }
        else if (cursors.down.isDown) {
           player.y += 4;
        }

        other_players.forEach(function(other_player) {
          var other_player_id = parseInt(other_player.player_id);

          if (other_player_id in world_state) {
            other_player.game_object.x = world_state[other_player_id].x
            other_player.game_object.y = world_state[other_player_id].y
          }
        })

        if (player_id_int in world_state) {
          if (world_state[player_id_int].x != player.x ||
                  world_state[player_id_int].y != player.y ) {
            channel.push("new_position", { player: player_id, position: { x: player.x, y: player.y }})
          }
        }
    }

    channel.on("update_world", payload => {

      world_state = payload

    })

    channel.on("new_player_joined", payload => {

      var other_player_id = payload.player_id
      var position = payload.position

      var new_player = game.add.sprite(position.x, position.y, 'sheep_1')
      new_player.anchor.setTo(0.5, 0.5)

      other_players.push({player_id: other_player_id, game_object: new_player})

    })

    channel.on("hello_world", payload => {

      Object.keys(payload).forEach(function(key) {
        if (key == player_id_int) { return }

        var new_player = game.add.sprite(payload[key].x, payload[key].y, 'sheep_1')
        new_player.anchor.setTo(0.5, 0.5);

        enemies.add(new_player)

        other_players.push({player_id: key, game_object: new_player})
      })

    })

};

</script>


feat(admin): add index page to admin menu

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin</title>
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/admin.css") %>">

      Lyn Admin

        <li class="nav-item <%= active_class(@conn, admin_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= admin_path(@conn, :index) %>">Home (current)

        <li class="nav-item <%= active_class(@conn, language_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= language_path(@conn, :index) %>">Languages (current)

        <li class="nav-item <%= active_class(@conn, domain_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= domain_path(@conn, :index) %>">Domains (current)

        <li class="nav-item <%= active_class(@conn, site_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= site_path(@conn, :index) %>">Sites (current)

      <form class="form-inline pull-xs-right">
        <input class="form-control" type="text" placeholder="Search">
        <button class="btn btn-success-outline" type="submit">Search</button>
      </form>

          sidebar

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

            <%= render @view_module, @view_template, assigns %>

<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Admin</title>
    <link rel="stylesheet" href="<%= static_path(@conn, "/css/admin.css") %>">

      Lyn Admin

        <li class="nav-item <%= active_class(@conn, page_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= page_path(@conn, :index) %>">Home (current)

        <li class="nav-item <%= active_class(@conn, language_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= language_path(@conn, :index) %>">Languages (current)

        <li class="nav-item <%= active_class(@conn, domain_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= domain_path(@conn, :index) %>">Domains (current)

        <li class="nav-item <%= active_class(@conn, site_path(@conn, :index)) %>">
          <a class="nav-link" href="<%= site_path(@conn, :index) %>">Sites (current)

      <form class="form-inline pull-xs-right">
        <input class="form-control" type="text" placeholder="Search">
        <button class="btn btn-success-outline" type="submit">Search</button>
      </form>

          sidebar

<%= get_flash(@conn, :info) %>

<%= get_flash(@conn, :error) %>

            <%= render @view_module, @view_template, assigns %>


Hide general deadline on registration page if no contests are shown

<%= gettext("Registration") %>

  <%= gettext("Here you can register for your local contest.") %>

<%= if @general_deadline do %>

    <%= gettext("Unless otherwise mentioned, the registration deadline is") %>
    <%= format_date(@general_deadline) %>.

<% end %>

<%= gettext("Jumu") %>

      <%= for contest <- @rw_contests do %>

          <%= link name_with_flag(contest),
            to: performance_path(@conn, :new, contest)
            %>
          <%= deadline_info(contest, @general_deadline) %>

      <% end %>

<%= gettext("Kimu") %>

      <%= for contest <- @kimu_contests do %>

          <%= link name_with_flag(contest),
            to: performance_path(@conn, :new, contest)
            %>

      <% end %>

  <%= gettext("Already registered?") %>

<%= link gettext("Edit your registration"),
  to: page_path(@conn, :edit_registration),
  class: "btn btn-default" %>

<%= gettext("Registration") %>

  <%= gettext("Here you can register for your local contest.") %>

  <%= gettext("Unless otherwise mentioned, the registration deadline is") %>
  <%= format_date(@general_deadline) %>.

<%= gettext("Jumu") %>

      <%= for contest <- @rw_contests do %>

          <%= link name_with_flag(contest),
            to: performance_path(@conn, :new, contest)
            %>
          <%= deadline_info(contest, @general_deadline) %>

      <% end %>

<%= gettext("Kimu") %>

      <%= for contest <- @kimu_contests do %>

          <%= link name_with_flag(contest),
            to: performance_path(@conn, :new, contest)
            %>

      <% end %>

  <%= gettext("Already registered?") %>

<%= link gettext("Edit your registration"),
  to: page_path(@conn, :edit_registration),
  class: "btn btn-default" %>


btn-xs bugfix for "Follow back" button.

btn-xs bugfix for "Follow back" button.

<%= full_name(@user) %>

      <%= if @user.first_name do %>

          <%= gettext "First name:" %>
          <%= @user.first_name %>

      <% end %>

      <%= if @user.last_name do %>

          <%= gettext "Last name:" %>
          <%= @user.last_name %>

      <% end %>

      <%= if @user.middlename do %>

          <%= gettext "Middlename:" %>
          <%= @user.middlename %>

      <% end %>

      <%= if @user.nickname do %>

          <%= gettext "Nickname:" %>
          <%= @user.nickname %>

      <% end %>

      <%= if @user.honorific_prefix do %>

          <%= gettext "Honorific prefix:" %>
          <%= @user.honorific_prefix %>

      <% end %>

      <%= if @user.honorific_suffix do %>

          <%= gettext "Honorific suffix:" %>
          <%= @user.honorific_suffix %>

      <% end %>

      <%= if @user.gender do %>

          <%= gettext "Gender:" %>
          <%= @user.gender %>

      <% end %>

      <%= if @user.birthdate do %>

          <%= gettext "Birthdate:" %>
          <%= @user.birthdate %>

      <% end %>

      <%= if @user.verified do %>

          <%= gettext "Verified:" %>
          <%= @user.verified %>

      <% end %>

    <%= link gettext("Edit"), to: user_path(@conn, :edit, @user) %>

    <%= if gravatar_url(@user) do %>
      <img src="<%= gravatar_url(@user) %>"  class="img-responsive img-rounded" alt="Avatar <%= full_name(@user) %>" />
    <% end %>

    <%= if @user.id != @current_user.id do %>
      <%= form_for @changeset, connection_path(@conn, :create), fn f -> %>
        <%= hidden_input f, :follower_id %>
        <%= hidden_input f, :followee_id %>

          <%= submit gettext("Follow"), class: "btn btn-primary" %>

      <% end %>
    <% end %>

    <%= unless Enum.empty?(@user.emails) do %>
      <%= render Vutuv.EmailView, "index.html", conn: @conn, emails: @user.emails, user: @user, emails_counter: @emails_counter %>
    <% end %>

    <%= unless Enum.empty?(@user.groups) do %>
      <%= render Vutuv.GroupView, "index.html", conn: @conn, groups: @user.groups, user: @user %>
    <% end %>

    <%= unless Enum.empty?(@user.followers) do %>

Followers

            Name

      <%= for connection <- @user.follower_connections do %>

              <%= if gravatar_url(connection.follower) do %>
              <img src="<%= gravatar_url(connection.follower) %>?s=20" />
              <% end %>

            <%= link full_name(connection.follower), to: user_path(@conn, :show, connection.follower) %>

              <%= link "Follow back", to: user_path(@conn, :follow_back, connection.follower), class: "btn btn-default btn-xs", role: "button" %>

      <% end %>

    <% end %>

    <%= unless Enum.empty?(@user.followees) do %>

Followees

            Name

      <%= for connection <- @user.followee_connections do %>

              <%= if gravatar_url(connection.followee) do %>
              <img src="<%= gravatar_url(connection.followee) %>?s=20" />
              <% end %>

            <%= link full_name(connection.followee), to: user_path(@conn, :show, connection.followee) %>

              <%= link gettext("Unfollow"), to: connection_path(@conn, :delete, connection), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>

      <% end %>

    <% end %>

<%= full_name(@user) %>

      <%= if @user.first_name do %>

          <%= gettext "First name:" %>
          <%= @user.first_name %>

      <% end %>

      <%= if @user.last_name do %>

          <%= gettext "Last name:" %>
          <%= @user.last_name %>

      <% end %>

      <%= if @user.middlename do %>

          <%= gettext "Middlename:" %>
          <%= @user.middlename %>

      <% end %>

      <%= if @user.nickname do %>

          <%= gettext "Nickname:" %>
          <%= @user.nickname %>

      <% end %>

      <%= if @user.honorific_prefix do %>

          <%= gettext "Honorific prefix:" %>
          <%= @user.honorific_prefix %>

      <% end %>

      <%= if @user.honorific_suffix do %>

          <%= gettext "Honorific suffix:" %>
          <%= @user.honorific_suffix %>

      <% end %>

      <%= if @user.gender do %>

          <%= gettext "Gender:" %>
          <%= @user.gender %>

      <% end %>

      <%= if @user.birthdate do %>

          <%= gettext "Birthdate:" %>
          <%= @user.birthdate %>

      <% end %>

      <%= if @user.verified do %>

          <%= gettext "Verified:" %>
          <%= @user.verified %>

      <% end %>

    <%= link gettext("Edit"), to: user_path(@conn, :edit, @user) %>

    <%= if gravatar_url(@user) do %>
      <img src="<%= gravatar_url(@user) %>"  class="img-responsive img-rounded" alt="Avatar <%= full_name(@user) %>" />
    <% end %>

    <%= if @user.id != @current_user.id do %>
      <%= form_for @changeset, connection_path(@conn, :create), fn f -> %>
        <%= hidden_input f, :follower_id %>
        <%= hidden_input f, :followee_id %>

          <%= submit gettext("Follow"), class: "btn btn-primary" %>

      <% end %>
    <% end %>

    <%= unless Enum.empty?(@user.emails) do %>
      <%= render Vutuv.EmailView, "index.html", conn: @conn, emails: @user.emails, user: @user, emails_counter: @emails_counter %>
    <% end %>

    <%= unless Enum.empty?(@user.groups) do %>
      <%= render Vutuv.GroupView, "index.html", conn: @conn, groups: @user.groups, user: @user %>
    <% end %>

    <%= unless Enum.empty?(@user.followers) do %>

Followers

            Name

      <%= for connection <- @user.follower_connections do %>

              <%= if gravatar_url(connection.follower) do %>
              <img src="<%= gravatar_url(connection.follower) %>?s=20" />
              <% end %>

            <%= link full_name(connection.follower), to: user_path(@conn, :show, connection.follower) %>

              <%= link "Follow back", to: user_path(@conn, :follow_back, connection.follower), class: "btn btn-default", role: "button" %>

      <% end %>

    <% end %>

    <%= unless Enum.empty?(@user.followees) do %>

Followees

            Name

      <%= for connection <- @user.followee_connections do %>

              <%= if gravatar_url(connection.followee) do %>
              <img src="<%= gravatar_url(connection.followee) %>?s=20" />
              <% end %>

            <%= link full_name(connection.followee), to: user_path(@conn, :show, connection.followee) %>

              <%= link gettext("Unfollow"), to: connection_path(@conn, :delete, connection), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>

      <% end %>

    <% end %>


keep erl_pipes in release dir

keep erl_pipes in release dir

#!/bin/sh

set -e

# Path to this script
SCRIPT=$(readlink $0 || true)
if [ -z $SCRIPT ]; then
    SCRIPT=$0
fi;
# Parent directory of this script
SCRIPT_DIR="$(cd `dirname "$SCRIPT"` && pwd -P)"
# Root directory of all releases
RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
# Name of the release
REL_NAME="<%= release_name %>"
# Current version of the release
REL_VSN="<%= release_version %>"
# Current version of ERTS being used
# If this is not present/unset, it will be detected
<%= unless is_nil(erts_vsn) do %>ERTS_VSN="<%= erts_vsn %>"<% end %>
# VM code loading mode, embedded by default, can also be interactive
# See http://erlang.org/doc/man/code.html
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
# Path to start_erl.data
START_ERL_DATA="$RELEASE_ROOT_DIR/releases/start_erl.data"
# Directory containing the current version of this release
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"
# The lib directory for this release
REL_LIB_DIR="$RELEASE_ROOT_DIR/lib"
# Options passed to erl
ERL_OPTS="<%= release.profile.erl_opts %>"
# When stdout is piped to a file, this is the directory those files will
# be stored in. defaults to /log in the release root directory
RUNNER_LOG_DIR="${RUNNER_LOG_DIR:-$RELEASE_ROOT_DIR/log}"
# A string of extra options to pass to erl, here for plugins
EXTRA_OPTS=""

# Pre-start/stop event hook paths
PRE_START_HOOK="$REL_DIR/hooks/pre_start"
POST_START_HOOK="$REL_DIR/hooks/post_start"
PRE_STOP_HOOK="$REL_DIR/hooks/pre_stop"
POST_STOP_HOOK="$REL_DIR/hooks/post_stop"

# Get node pid
get_pid() {
    if output="$(nodetool rpcterms os getpid)"
    then
        echo "$output" | sed -e 's/"//g'
        return 0
    else
        echo "$output"
        return 1
    fi
}

# Generate a unique nodename
gen_nodename() {
    id="longname$(gen_id)-${NAME}"
    "$BINDIR/erl" -boot start_clean -eval '[Host] = tl(string:tokens(atom_to_list(node()),"@")), io:format("~s~n", [Host]), halt()' -noshell ${NAME_TYPE} $id
}

# Generate a random id
gen_id() {
    od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
}

# Control a node
# Use like `nodetool "ping"`
nodetool() {
    command="$1"; shift

    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \
                            -setcookie "$COOKIE" "$command" $@
}

# Run an escript in the node's environment
# Use like `escript "path/to/escript"`
escript() {
    shift; scriptpath="$1"; shift
    export RELEASE_ROOT_DIR

    "$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@
}

# Private. For determining the version of ERTS available to the release
_detect_erts_vsn() {
    erl -boot start_clean -eval 'Ver = erlang:system_info(version), io:format("~s~n", [Ver]), halt()' -noshell
}

# Private. For setting ERTS_DIR and ROOTDIR
_find_erts_dir() {
    __erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN"
    if [ -d "$__erts_dir" ]; then
        ERTS_DIR="$__erts_dir";
        ROOTDIR="$RELEASE_ROOT_DIR"
    else
        __erl="$(which erl)"
        code="io:format(\"~s\", [code:root_dir()]), halt()."
        __erl_root="$("$__erl" -noshell -eval "$code")"
        ERTS_DIR="$__erl_root/erts-$ERTS_VSN"
        ROOTDIR="$__erl_root"
    fi
}

# Private. Open a shell on a remote node
_rem_sh() {
    # Generate a unique id used to allow multiple remsh to the same node
    # transparently
    id="remsh$(gen_id)-${NAME}"

    # Get the node's ticktime so that we use the same thing.
    TICKTIME="$(nodetool rpcterms net_kernel get_net_ticktime)"

    # Setup remote shell command to control node
    if [ ! -z "$USE_ERL_SHELL" ]; then
        exec "$BINDIR/erl" \
            -hidden \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            "$NAME_TYPE" "$id" -remsh "$NAME" -setcookie "$COOKIE"
    else
        exec "$BINDIR/erl" \
            -pa "$ROOTDIR"/lib/*/ebin -pa "$CONSOLIDATED_DIR" \
            -hidden -noshell \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            -user Elixir.IEx.CLI "$NAME_TYPE" "$id" -setcookie "$COOKIE" \
            -extra --no-halt +iex -"$NAME_TYPE" "$id" --cookie "$COOKIE" --remsh "$NAME"
    fi
}

# Output a start command for the last argument of run_erl
_start_command() {
    printf "exec \"%s\" \"%s\" -- %s %s" "$RELEASE_ROOT_DIR/bin/$REL_NAME" \
           "$START_OPTION" "${ARGS}" "${EXTRA_OPTS}"
}

# If ERTS_VSN is not set, detect it
if [ -z "$ERTS_VSN" ]; then
    ERTS_VSN="$(_detect_erts_vsn)"
    echo "$ERTS_VSN $REL_VSN" > "$START_ERL_DATA"
fi

# Allow override of where to look for config files
# By default it's $CWD/
if [ -z "$RELEASE_CONFIG_DIR" ]; then
    RELEASE_CONFIG_DIR="$RELEASE_ROOT_DIR"
fi

# Set VMARGS_PATH, the path to the vm.args file to use
# Use $RELEASE_CONFIG_DIR/vm.args if exists, otherwise releases/VSN/vm.args
if [ -z "$VMARGS_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/vm.args" ]; then
        VMARGS_PATH="$RELEASE_CONFIG_DIR/vm.args"
    else
        VMARGS_PATH="$REL_DIR/vm.args"
    fi
fi

orig_vmargs_path="$VMARGS_PATH.orig"
if [ $REPLACE_OS_VARS ]; then
    #Make sure we don't break dev mode by keeping the symbolic link to
    #the user's vm.args
    if [ ! -L "$orig_vmargs_path" ]; then
       #we're in copy mode, rename the vm.args file to vm.args.orig
       mv "$VMARGS_PATH" "$orig_vmargs_path"
    fi

    awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_vmargs_path" > "$VMARGS_PATH"
 else
    #We don't need to replace env. vars, just rename the
    #symlink vm.args.orig to vm.args, and keep it as a
    #symlink.
    if [ -L "$orig_vmargs_path" ]; then
       mv "$orig_vmargs_path" "$VMARGS_PATH"
    fi
fi

# Make sure log directory exists
mkdir -p "$RUNNER_LOG_DIR"

# Set SYS_CONFIG_PATH, the path to the sys.config file to use
# Use $RELEASE_CONFIG_DIR/sys.config if exists, otherwise releases/VSN/sys.config
if [ -z "$SYS_CONFIG_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/sys.config" ]; then
        SYS_CONFIG_PATH="$RELEASE_CONFIG_DIR/sys.config"
    else
        SYS_CONFIG_PATH="$REL_DIR/sys.config"
    fi
fi

orig_sys_config_path="$SYS_CONFIG_PATH.orig"
if [ $REPLACE_OS_VARS ]; then
    #Make sure we don't break dev mode by keeping the symbolic link to
    #the user's sys.config
    if [ ! -L "$orig_sys_config_path" ]; then
       #We're in copy mode, rename sys.config to sys.config.orig
       mv "$SYS_CONFIG_PATH" "$orig_sys_config_path"
    fi

    awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_sys_config_path" > "$SYS_CONFIG_PATH"
 else
    #We don't need to replace env. vars, just rename the
    #symlink sys.config.orig to sys.config. Keep it as
    #a symlink.
    if [ -L "$orig_sys_config_path" ]; then
       mv "$orig_sys_config_path"  "$SYS_CONFIG_PATH"
    fi
fi

# Extract the target node name from node.args
# Should be `-sname somename` or `-name somename@somehost`
NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true)
if [ -z "$NAME_ARG" ]; then
    echo "vm.args needs to have either -name or -sname parameter."
    exit 1
fi

# Extract the name type and name from the NAME_ARG for REMSH
# NAME_TYPE should be -name or -sname
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
# NAME will be either `somename` or `somename@somehost`
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"

# Where the pipe will be stored when using `start`
# This is used so you can attach the running application to the current
# shell using `attach`
PIPE_DIR="${PIPE_DIR:-$RELEASE_ROOT_DIR/tmp/erl_pipes/$NAME/}"

# Extract the target cookie
COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
DEFAULT_COOKIE_FILE="$HOME/.erlang.cookie"
if [ -z "$COOKIE_ARG" ]; then
    if [ -f "$DEFAULT_COOKIE_FILE" ]; then
        COOKIE="$(cat "$DEFAULT_COOKIE_FILE")"
    else
        printf "a secret cookie must be provided in one of the following ways:\n  - with vm.args using the -setcookie parameter,\n  or\n  by writing the cookie to '$DEFAULT_COOKIE_FILE', with permissions set to 0400"
        exit 1
    fi
else
    # Extract cookie name from COOKIE_ARG
    COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
fi

_find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$ERTS_DIR/../lib"
CONSOLIDATED_DIR="$ROOTDIR/lib/${REL_NAME}-${REL_VSN}/consolidated"

cd "$ROOTDIR"

# User can specify an sname without @hostname
# This will fail when creating remote shell
# So here we check for @ and add @hostname if missing
case $NAME in
    *@*)
        # Nothing to do
        ;;
    *)
        NAME=$NAME@$(gen_nodename)
        ;;
esac

# Check the first argument for instructions
case "$1" in
    start|start_boot)

        # Make sure there is not already a node running
        #RES=`$NODETOOL ping`
        #if [ "$RES" = "pong" ]; then
        #    echo "Node is already running!"
        #    exit 1
        #fi
        # Save this for later.
        CMD=$1
        case "$1" in
            start)
                shift
                START_OPTION="console"
                HEART_OPTION="start"
                ;;
            start_boot)
                shift
                START_OPTION="console_boot"
                HEART_OPTION="start_boot"
                ;;
        esac
        ARGS="$@"
        RUN_PARAM="$@"

        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Set arguments for the heart command
        set -- "$SCRIPT_DIR/$REL_NAME" "$HEART_OPTION"
        [ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM"

        # Export the HEART_COMMAND
        HEART_COMMAND="$RELEASE_ROOT_DIR/bin/$REL_NAME $CMD"
        export HEART_COMMAND

        mkdir -p "$PIPE_DIR"

        "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \
                          "$(_start_command)"

        [ -f "$POST_START_HOOK" ] && . "$POST_START_HOOK"
        ;;

    stop)
        [ -f "$PRE_STOP_HOOK" ] && . "$PRE_STOP_HOOK"
        # Wait for the node to completely stop...
        PID="$(get_pid)"
        if ! nodetool "stop"; then
            exit 1
        fi
        while $(kill -s 0 "$PID" 2>/dev/null);
        do
            sleep 1
        done
        [ -f "$POST_STOP_HOOK" ] && . "$POST_STOP_HOOK"
        ;;

    restart)
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"
        ## Restart the VM without exiting the process
        if ! nodetool "restart"; then
            exit 1
        fi
        ;;

    reboot)
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"
        ## Restart the VM completely (uses heart to restart it)
        if ! nodetool "reboot"; then
            exit 1
        fi
        ;;

    pid)
        ## Get the VM's pid
        if ! get_pid; then
            exit 1
        fi
        ;;

    ping)
        ## See if the VM is alive
        if ! nodetool "ping"; then
            exit 1
        fi
        ;;

    escript)
        ## Run an escript under the node's environment
        if ! escript $@; then
            exit 1
        fi
        ;;

    attach)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        exec "$BINDIR/to_erl" "$PIPE_DIR"
        ;;

    remote_console)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        _rem_sh
        ;;

    upgrade|downgrade|install)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
             "install" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    unpack)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
             "unpack" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    console|console_clean|console_boot)
        # .boot file typically just $REL_NAME (ie, the app name)
        # however, for debugging, sometimes start_clean.boot is useful.
        # For e.g. 'setup', one may even want to name another boot script.
        case "$1" in
            console)
                if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
                  BOOTFILE="$REL_DIR/$REL_NAME"
                else
                  BOOTFILE="$REL_DIR/start"
                fi
                ;;
            console_clean)
                BOOTFILE="$ROOTDIR/bin/start_clean"
                ;;
            console_boot)
                shift
                BOOTFILE="$1"
                shift
                ;;
        esac
        # Setup beam-required vars
        EMU="beam"
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        # Start the VM, executing pre_start hook along
        # the way. We can't run the post_start hook because
        # the console will crash with no TTY attached
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" \
            -boot "$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -user Elixir.IEx.CLI \
            -extra --no-halt +iex

        # Dump environment info for logging purposes
        echo "Exec: $@" -- ${1+$ARGS} ${EXTRA_OPTS}
        echo "Root: $ROOTDIR"

        # Log the startup
        echo "$RELEASE_ROOT_DIR"
        logger -t "$REL_NAME[$$]" "Starting up"

        exec "$@" -- ${1+$ARGS} ${EXTRA_OPTS}
        ;;

    foreground)
        # start up the release in the foreground for use by runit
        # or other supervision services

        [ -f "$REL_DIR/$REL_NAME.boot" ] && BOOTFILE="$REL_NAME" || BOOTFILE=start
        FOREGROUNDOPTIONS="-noshell -noinput +Bd"

        # Setup beam-required vars
        EMU=beam
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        # Start the VM, executing pre and post start hooks
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
            -boot "$REL_DIR/$BOOTFILE" -mode "$CODE_LOADING_MODE" -config "$SYS_CONFIG_PATH" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -args_file "$VMARGS_PATH" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            ${ERL_OPTS} \
            -extra ${EXTRA_OPTS}

        # Dump environment info for logging purposes
        echo "Exec: $@" -- ${1+$ARGS}
        echo "Root: $ROOTDIR"

        trap '{}' QUIT TERM KILL HUP SIGUSR1 SIGUSR2
        "$@" -- ${1+$ARGS} &
        __bg_pid=$!
        [ -f "$POST_START_HOOK" ] && . "$POST_START_HOOK"
        wait $__bg_pid
        ;;
    rpc)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpc $@
        ;;
    rpcterms)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpcterms $@
        ;;
    eval)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        nodetool "eval" $@
        ;;
    command)
        # Execute as command-line utility
        #
        # Like the escript command, this does not start the OTP application.
        # If your command depends on a running OTP application,
        # use
        #
        #     {:ok, _} = Application.ensure_all_started(:your_app)

        shift
        MODULE="$1"; shift
        FUNCTION="$1"; shift

        # Save extra arguments
        ARGS="$@"

        # Build arguments for erlexec
        set -- "$ERL_OPTS"
        [ "$SYS_CONFIG_PATH" ] && set -- "$@" -config "$SYS_CONFIG_PATH"
        set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR"
        set -- "$@" -noshell
        set -- "$@" -boot start_clean
        set -- "$@" -s "$MODULE" "$FUNCTION"

        $BINDIR/erlexec $@ -extra $ARGS
        exit "$?"
        ;;
    *)
        __command_path="$REL_DIR/commands/$1"
        if [ -f "$__command_path" ]; then
            . "$__command_path"
        else
            echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade|downgrade|install|escript|rpc|rpcterms|eval|command <module> <function> <args>}"
            exit 1
        fi
        ;;
esac

exit 0

#!/bin/sh

set -e

# Path to this script
SCRIPT=$(readlink $0 || true)
if [ -z $SCRIPT ]; then
    SCRIPT=$0
fi;
# Parent directory of this script
SCRIPT_DIR="$(cd `dirname "$SCRIPT"` && pwd -P)"
# Root directory of all releases
RELEASE_ROOT_DIR="$(cd "$SCRIPT_DIR/../.." && pwd -P)"
# Name of the release
REL_NAME="<%= release_name %>"
# Current version of the release
REL_VSN="<%= release_version %>"
# Current version of ERTS being used
# If this is not present/unset, it will be detected
<%= unless is_nil(erts_vsn) do %>ERTS_VSN="<%= erts_vsn %>"<% end %>
# VM code loading mode, embedded by default, can also be interactive
# See http://erlang.org/doc/man/code.html
CODE_LOADING_MODE="${CODE_LOADING_MODE:-embedded}"
# Path to start_erl.data
START_ERL_DATA="$RELEASE_ROOT_DIR/releases/start_erl.data"
# Directory containing the current version of this release
REL_DIR="$RELEASE_ROOT_DIR/releases/$REL_VSN"
# The lib directory for this release
REL_LIB_DIR="$RELEASE_ROOT_DIR/lib"
# Options passed to erl
ERL_OPTS="<%= release.profile.erl_opts %>"
# When stdout is piped to a file, this is the directory those files will
# be stored in. defaults to /log in the release root directory
RUNNER_LOG_DIR="${RUNNER_LOG_DIR:-$RELEASE_ROOT_DIR/log}"
# A string of extra options to pass to erl, here for plugins
EXTRA_OPTS=""

# Pre-start/stop event hook paths
PRE_START_HOOK="$REL_DIR/hooks/pre_start"
POST_START_HOOK="$REL_DIR/hooks/post_start"
PRE_STOP_HOOK="$REL_DIR/hooks/pre_stop"
POST_STOP_HOOK="$REL_DIR/hooks/post_stop"

# Get node pid
get_pid() {
    if output="$(nodetool rpcterms os getpid)"
    then
        echo "$output" | sed -e 's/"//g'
        return 0
    else
        echo "$output"
        return 1
    fi
}

# Generate a unique nodename
gen_nodename() {
    id="longname$(gen_id)-${NAME}"
    "$BINDIR/erl" -boot start_clean -eval '[Host] = tl(string:tokens(atom_to_list(node()),"@")), io:format("~s~n", [Host]), halt()' -noshell ${NAME_TYPE} $id
}

# Generate a random id
gen_id() {
    od -t x -N 4 /dev/urandom | head -n1 | awk '{print $2}'
}

# Control a node
# Use like `nodetool "ping"`
nodetool() {
    command="$1"; shift

    "$ERTS_DIR/bin/escript" "$ROOTDIR/bin/nodetool" "$NAME_TYPE" "$NAME" \
                            -setcookie "$COOKIE" "$command" $@
}

# Run an escript in the node's environment
# Use like `escript "path/to/escript"`
escript() {
    shift; scriptpath="$1"; shift
    export RELEASE_ROOT_DIR

    "$ERTS_DIR/bin/escript" "$ROOTDIR/$scriptpath" $@
}

# Private. For determining the version of ERTS available to the release
_detect_erts_vsn() {
    erl -boot start_clean -eval 'Ver = erlang:system_info(version), io:format("~s~n", [Ver]), halt()' -noshell
}

# Private. For setting ERTS_DIR and ROOTDIR
_find_erts_dir() {
    __erts_dir="$RELEASE_ROOT_DIR/erts-$ERTS_VSN"
    if [ -d "$__erts_dir" ]; then
        ERTS_DIR="$__erts_dir";
        ROOTDIR="$RELEASE_ROOT_DIR"
    else
        __erl="$(which erl)"
        code="io:format(\"~s\", [code:root_dir()]), halt()."
        __erl_root="$("$__erl" -noshell -eval "$code")"
        ERTS_DIR="$__erl_root/erts-$ERTS_VSN"
        ROOTDIR="$__erl_root"
    fi
}

# Private. Open a shell on a remote node
_rem_sh() {
    # Generate a unique id used to allow multiple remsh to the same node
    # transparently
    id="remsh$(gen_id)-${NAME}"

    # Get the node's ticktime so that we use the same thing.
    TICKTIME="$(nodetool rpcterms net_kernel get_net_ticktime)"

    # Setup remote shell command to control node
    if [ ! -z "$USE_ERL_SHELL" ]; then
        exec "$BINDIR/erl" \
            -hidden \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            "$NAME_TYPE" "$id" -remsh "$NAME" -setcookie "$COOKIE"
    else
        exec "$BINDIR/erl" \
            -pa "$ROOTDIR"/lib/*/ebin -pa "$CONSOLIDATED_DIR" \
            -hidden -noshell \
            -boot start_clean -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -kernel net_ticktime $TICKTIME \
            -user Elixir.IEx.CLI "$NAME_TYPE" "$id" -setcookie "$COOKIE" \
            -extra --no-halt +iex -"$NAME_TYPE" "$id" --cookie "$COOKIE" --remsh "$NAME"
    fi
}

# Output a start command for the last argument of run_erl
_start_command() {
    printf "exec \"%s\" \"%s\" -- %s %s" "$RELEASE_ROOT_DIR/bin/$REL_NAME" \
           "$START_OPTION" "${ARGS}" "${EXTRA_OPTS}"
}

# If ERTS_VSN is not set, detect it
if [ -z "$ERTS_VSN" ]; then
    ERTS_VSN="$(_detect_erts_vsn)"
    echo "$ERTS_VSN $REL_VSN" > "$START_ERL_DATA"
fi

# Allow override of where to look for config files
# By default it's $CWD/
if [ -z "$RELEASE_CONFIG_DIR" ]; then
    RELEASE_CONFIG_DIR="$RELEASE_ROOT_DIR"
fi

# Set VMARGS_PATH, the path to the vm.args file to use
# Use $RELEASE_CONFIG_DIR/vm.args if exists, otherwise releases/VSN/vm.args
if [ -z "$VMARGS_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/vm.args" ]; then
        VMARGS_PATH="$RELEASE_CONFIG_DIR/vm.args"
    else
        VMARGS_PATH="$REL_DIR/vm.args"
    fi
fi

orig_vmargs_path="$VMARGS_PATH.orig"
if [ $REPLACE_OS_VARS ]; then
    #Make sure we don't break dev mode by keeping the symbolic link to
    #the user's vm.args
    if [ ! -L "$orig_vmargs_path" ]; then
       #we're in copy mode, rename the vm.args file to vm.args.orig
       mv "$VMARGS_PATH" "$orig_vmargs_path"
    fi

    awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_vmargs_path" > "$VMARGS_PATH"
 else
    #We don't need to replace env. vars, just rename the
    #symlink vm.args.orig to vm.args, and keep it as a
    #symlink.
    if [ -L "$orig_vmargs_path" ]; then
       mv "$orig_vmargs_path" "$VMARGS_PATH"
    fi
fi

# Make sure log directory exists
mkdir -p "$RUNNER_LOG_DIR"

# Set SYS_CONFIG_PATH, the path to the sys.config file to use
# Use $RELEASE_CONFIG_DIR/sys.config if exists, otherwise releases/VSN/sys.config
if [ -z "$SYS_CONFIG_PATH" ]; then
    if [ -f "$RELEASE_CONFIG_DIR/sys.config" ]; then
        SYS_CONFIG_PATH="$RELEASE_CONFIG_DIR/sys.config"
    else
        SYS_CONFIG_PATH="$REL_DIR/sys.config"
    fi
fi

orig_sys_config_path="$SYS_CONFIG_PATH.orig"
if [ $REPLACE_OS_VARS ]; then
    #Make sure we don't break dev mode by keeping the symbolic link to
    #the user's sys.config
    if [ ! -L "$orig_sys_config_path" ]; then
       #We're in copy mode, rename sys.config to sys.config.orig
       mv "$SYS_CONFIG_PATH" "$orig_sys_config_path"
    fi

    awk '{while(match($0,"[$]{[^}]*}")) {var=substr($0,RSTART+2,RLENGTH -3);gsub("[$]{"var"}",ENVIRON[var])}}1' < "$orig_sys_config_path" > "$SYS_CONFIG_PATH"
 else
    #We don't need to replace env. vars, just rename the
    #symlink sys.config.orig to sys.config. Keep it as
    #a symlink.
    if [ -L "$orig_sys_config_path" ]; then
       mv "$orig_sys_config_path"  "$SYS_CONFIG_PATH"
    fi
fi

# Extract the target node name from node.args
# Should be `-sname somename` or `-name somename@somehost`
NAME_ARG=$(egrep '^-s?name' "$VMARGS_PATH" || true)
if [ -z "$NAME_ARG" ]; then
    echo "vm.args needs to have either -name or -sname parameter."
    exit 1
fi

# Extract the name type and name from the NAME_ARG for REMSH
# NAME_TYPE should be -name or -sname
NAME_TYPE="$(echo "$NAME_ARG" | awk '{print $1}')"
# NAME will be either `somename` or `somename@somehost`
NAME="$(echo "$NAME_ARG" | awk '{print $2}')"

# Where the pipe will be stored when using `start`
# This is used so you can attach the running application to the current
# shell using `attach`
PIPE_DIR="${PIPE_DIR:-/tmp/erl_pipes/$NAME/}"

# Extract the target cookie
COOKIE_ARG="$(grep '^-setcookie' "$VMARGS_PATH" || true)"
DEFAULT_COOKIE_FILE="$HOME/.erlang.cookie"
if [ -z "$COOKIE_ARG" ]; then
    if [ -f "$DEFAULT_COOKIE_FILE" ]; then
        COOKIE="$(cat "$DEFAULT_COOKIE_FILE")"
    else
        printf "a secret cookie must be provided in one of the following ways:\n  - with vm.args using the -setcookie parameter,\n  or\n  by writing the cookie to '$DEFAULT_COOKIE_FILE', with permissions set to 0400"
        exit 1
    fi
else
    # Extract cookie name from COOKIE_ARG
    COOKIE="$(echo "$COOKIE_ARG" | awk '{print $2}')"
fi

_find_erts_dir
export ROOTDIR="$RELEASE_ROOT_DIR"
export BINDIR="$ERTS_DIR/bin"
export EMU="beam"
export PROGNAME="erl"
export LD_LIBRARY_PATH="$ERTS_DIR/lib:$LD_LIBRARY_PATH"
ERTS_LIB_DIR="$ERTS_DIR/../lib"
CONSOLIDATED_DIR="$ROOTDIR/lib/${REL_NAME}-${REL_VSN}/consolidated"

cd "$ROOTDIR"

# User can specify an sname without @hostname
# This will fail when creating remote shell
# So here we check for @ and add @hostname if missing
case $NAME in
    *@*)
        # Nothing to do
        ;;
    *)
        NAME=$NAME@$(gen_nodename)
        ;;
esac

# Check the first argument for instructions
case "$1" in
    start|start_boot)

        # Make sure there is not already a node running
        #RES=`$NODETOOL ping`
        #if [ "$RES" = "pong" ]; then
        #    echo "Node is already running!"
        #    exit 1
        #fi
        # Save this for later.
        CMD=$1
        case "$1" in
            start)
                shift
                START_OPTION="console"
                HEART_OPTION="start"
                ;;
            start_boot)
                shift
                START_OPTION="console_boot"
                HEART_OPTION="start_boot"
                ;;
        esac
        ARGS="$@"
        RUN_PARAM="$@"

        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Set arguments for the heart command
        set -- "$SCRIPT_DIR/$REL_NAME" "$HEART_OPTION"
        [ "$RUN_PARAM" ] && set -- "$@" "$RUN_PARAM"

        # Export the HEART_COMMAND
        HEART_COMMAND="$RELEASE_ROOT_DIR/bin/$REL_NAME $CMD"
        export HEART_COMMAND

        mkdir -p "$PIPE_DIR"

        "$BINDIR/run_erl" -daemon "$PIPE_DIR" "$RUNNER_LOG_DIR" \
                          "$(_start_command)"

        [ -f "$POST_START_HOOK" ] && . "$POST_START_HOOK"
        ;;

    stop)
        [ -f "$PRE_STOP_HOOK" ] && . "$PRE_STOP_HOOK"
        # Wait for the node to completely stop...
        PID="$(get_pid)"
        if ! nodetool "stop"; then
            exit 1
        fi
        while $(kill -s 0 "$PID" 2>/dev/null);
        do
            sleep 1
        done
        [ -f "$POST_STOP_HOOK" ] && . "$POST_STOP_HOOK"
        ;;

    restart)
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"
        ## Restart the VM without exiting the process
        if ! nodetool "restart"; then
            exit 1
        fi
        ;;

    reboot)
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"
        ## Restart the VM completely (uses heart to restart it)
        if ! nodetool "reboot"; then
            exit 1
        fi
        ;;

    pid)
        ## Get the VM's pid
        if ! get_pid; then
            exit 1
        fi
        ;;

    ping)
        ## See if the VM is alive
        if ! nodetool "ping"; then
            exit 1
        fi
        ;;

    escript)
        ## Run an escript under the node's environment
        if ! escript $@; then
            exit 1
        fi
        ;;

    attach)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        exec "$BINDIR/to_erl" "$PIPE_DIR"
        ;;

    remote_console)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        _rem_sh
        ;;

    upgrade|downgrade|install)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
             "install" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    unpack)
        if [ -z "$2" ]; then
            echo "Missing package argument"
            echo "Usage: $REL_NAME $1 {package base name}"
            echo "NOTE {package base name} MUST NOT include the .tar.gz suffix"
            exit 1
        fi

        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        exec "$BINDIR/escript" "$ROOTDIR/bin/install_upgrade.escript" \
             "unpack" "$REL_NAME" "$NAME_TYPE" "$NAME" "$COOKIE" "$2"
        ;;

    console|console_clean|console_boot)
        # .boot file typically just $REL_NAME (ie, the app name)
        # however, for debugging, sometimes start_clean.boot is useful.
        # For e.g. 'setup', one may even want to name another boot script.
        case "$1" in
            console)
                if [ -f "$REL_DIR/$REL_NAME.boot" ]; then
                  BOOTFILE="$REL_DIR/$REL_NAME"
                else
                  BOOTFILE="$REL_DIR/start"
                fi
                ;;
            console_clean)
                BOOTFILE="$ROOTDIR/bin/start_clean"
                ;;
            console_boot)
                shift
                BOOTFILE="$1"
                shift
                ;;
        esac
        # Setup beam-required vars
        EMU="beam"
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        # Start the VM, executing pre_start hook along
        # the way. We can't run the post_start hook because
        # the console will crash with no TTY attached
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" \
            -boot "$BOOTFILE" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            -args_file "$VMARGS_PATH" \
            -config "$SYS_CONFIG_PATH" \
            -mode "$CODE_LOADING_MODE" \
            ${ERL_OPTS} \
            -user Elixir.IEx.CLI \
            -extra --no-halt +iex

        # Dump environment info for logging purposes
        echo "Exec: $@" -- ${1+$ARGS} ${EXTRA_OPTS}
        echo "Root: $ROOTDIR"

        # Log the startup
        echo "$RELEASE_ROOT_DIR"
        logger -t "$REL_NAME[$$]" "Starting up"

        exec "$@" -- ${1+$ARGS} ${EXTRA_OPTS}
        ;;

    foreground)
        # start up the release in the foreground for use by runit
        # or other supervision services

        [ -f "$REL_DIR/$REL_NAME.boot" ] && BOOTFILE="$REL_NAME" || BOOTFILE=start
        FOREGROUNDOPTIONS="-noshell -noinput +Bd"

        # Setup beam-required vars
        EMU=beam
        PROGNAME="${0#*/}"

        export EMU
        export PROGNAME

        # Store passed arguments since they will be erased by `set`
        ARGS="$@"

        # Start the VM, executing pre and post start hooks
        [ -f "$PRE_START_HOOK" ] && . "$PRE_START_HOOK"

        # Build an array of arguments to pass to exec later on
        # Build it here because this command will be used for logging.
        set -- "$BINDIR/erlexec" $FOREGROUNDOPTIONS \
            -boot "$REL_DIR/$BOOTFILE" -mode "$CODE_LOADING_MODE" -config "$SYS_CONFIG_PATH" \
            -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR" \
            -args_file "$VMARGS_PATH" \
            -env ERL_LIBS "$REL_LIB_DIR" \
            -pa "$CONSOLIDATED_DIR" \
            ${ERL_OPTS} \
            -extra ${EXTRA_OPTS}

        # Dump environment info for logging purposes
        echo "Exec: $@" -- ${1+$ARGS}
        echo "Root: $ROOTDIR"

        trap '{}' QUIT TERM KILL HUP SIGUSR1 SIGUSR2
        "$@" -- ${1+$ARGS} &
        __bg_pid=$!
        [ -f "$POST_START_HOOK" ] && . "$POST_START_HOOK"
        wait $__bg_pid
        ;;
    rpc)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpc $@
        ;;
    rpcterms)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift

        nodetool rpcterms $@
        ;;
    eval)
        # Make sure a node IS running
        if ! nodetool "ping" > /dev/null; then
            echo "Node is not running!"
            exit 1
        fi

        shift
        nodetool "eval" $@
        ;;
    command)
        # Execute as command-line utility
        #
        # Like the escript command, this does not start the OTP application.
        # If your command depends on a running OTP application,
        # use
        #
        #     {:ok, _} = Application.ensure_all_started(:your_app)

        shift
        MODULE="$1"; shift
        FUNCTION="$1"; shift

        # Save extra arguments
        ARGS="$@"

        # Build arguments for erlexec
        set -- "$ERL_OPTS"
        [ "$SYS_CONFIG_PATH" ] && set -- "$@" -config "$SYS_CONFIG_PATH"
        set -- "$@" -boot_var ERTS_LIB_DIR "$ERTS_LIB_DIR"
        set -- "$@" -noshell
        set -- "$@" -boot start_clean
        set -- "$@" -s "$MODULE" "$FUNCTION"

        $BINDIR/erlexec $@ -extra $ARGS
        exit "$?"
        ;;
    *)
        __command_path="$REL_DIR/commands/$1"
        if [ -f "$__command_path" ]; then
            . "$__command_path"
        else
            echo "Usage: $REL_NAME {start|start_boot <file>|foreground|stop|restart|reboot|pid|ping|console|console_clean|console_boot <file>|attach|remote_console|upgrade|downgrade|install|escript|rpc|rpcterms|eval|command <module> <function> <args>}"
            exit 1
        fi
        ;;
esac

exit 0


delete episode button in admin show view

Show episode

  <%= link "Edit", to: episode_path(@conn, :edit, @episode), class: "btn btn-warning" %>

  <%= link "Delete", to: episode_path(@conn, :delete, @episode),
                     method: :delete,
                     data: [confirm: "Are you sure?"],
                     class: "btn btn-danger" %>

Title

<%= @episode.title %>

Link

<a href="<%= @episode.link %>"><%= @episode.link %>

Publishing date

<%= @episode.publishing_date %>

Guid

<%= @episode.guid %>

Description

<%= @episode.description %>

Shownotes

<%= raw(@episode.shownotes) %>

Payment link

<a href="<%= @episode.payment_link_url %>"><%= @episode.payment_link_title %>

Image

<a href="<%= @episode.image_url %>"><%= @episode.image_title %>

Deep link

<%= @episode.deep_link %>

Duration

<%= @episode.duration %>

Contributors

  <%= for contributor <- @episode.contributors do %>

<%= contributor.name %>

  <% end %>

Subtitle

<%= @episode.subtitle %>

Summary

<%= @episode.summary %>

Podcast

<%= @episode.podcast.title %>

Elastic

<%= @episode.elastic %>

Thumbnail created

<%= @episode.thumbnailed %>

Inserted at

<%= @episode.inserted_at %>

Updated at

<%= @episode.updated_at %>

<%= render "_enclosures.html", enclosures: @episode.enclosures, conn: @conn %>

<%= render "_chapters.html", chapters: @episode.chapters, conn: @conn %>

<%= render PanWeb.PodcastView, "_podcast.html", podcast: @episode.podcast, conn: @conn %>

<%= link "Edit", to: episode_path(@conn, :edit, @episode) %>
<%= link "Back", to: episode_path(@conn, :index) %>

Show episode

  <%= link "Edit", to: episode_path(@conn, :edit, @episode), class: "btn btn-warning" %>

Title

<%= @episode.title %>

Link

<a href="<%= @episode.link %>"><%= @episode.link %>

Publishing date

<%= @episode.publishing_date %>

Guid

<%= @episode.guid %>

Description

<%= @episode.description %>

Shownotes

<%= raw(@episode.shownotes) %>

Payment link

<a href="<%= @episode.payment_link_url %>"><%= @episode.payment_link_title %>

Image

<a href="<%= @episode.image_url %>"><%= @episode.image_title %>

Deep link

<%= @episode.deep_link %>

Duration

<%= @episode.duration %>

Contributors

  <%= for contributor <- @episode.contributors do %>

<%= contributor.name %>

  <% end %>

Subtitle

<%= @episode.subtitle %>

Summary

<%= @episode.summary %>

Podcast

<%= @episode.podcast.title %>

Elastic

<%= @episode.elastic %>

Thumbnail created

<%= @episode.thumbnailed %>

Inserted at

<%= @episode.inserted_at %>

Updated at

<%= @episode.updated_at %>

<%= render "_enclosures.html", enclosures: @episode.enclosures, conn: @conn %>

<%= render "_chapters.html", chapters: @episode.chapters, conn: @conn %>

<%= render PanWeb.PodcastView, "_podcast.html", podcast: @episode.podcast, conn: @conn %>

<%= link "Edit", to: episode_path(@conn, :edit, @episode) %>
<%= link "Back", to: episode_path(@conn, :index) %>


Keep the first call panel open by default

<%= for {call, index} <- Enum.with_index(@stub_url.calls) do %>

    <div class="panel-heading" role="tab" id="call-<%= call.id %>-heading">

        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#call-<%= call.id %>" aria-expanded="true" aria-controls="collapseOne">
			<span data-time="<%= call.inserted_at |> Ecto.DateTime.to_iso8601 %>"><%= call.inserted_at |> Ecto.DateTime.to_iso8601%> |
			 <%= call.request.method %>  <%= call.request.url %>
			<%= call.response.status %>

    <div id="call-<%= call.id %>" class="panel-collapse collapse <%= if(index==0) do "in" end %>" role="tabpanel" aria-labelledby="call-<%= call.id %>-heading">

		    	<a href="#call-<%= call.id %>-request" aria-controls="call-<%= call.id %>-request" role="tab" data-toggle="tab">Request

		    	<a href="#call-<%= call.id %>-response" aria-controls="call-<%= call.id %>-response" role="tab" data-toggle="tab">Response

		    <div role="tabpanel" class="tab-pane active" id="call-<%= call.id %>-request">
				<%= render "_http_body.html", body: call.request.body %>
				<%= render "_http_headers.html", headers: call.request.headers %>

		    <div role="tabpanel" class="tab-pane" id="call-<%= call.id %>-response">

Status: <%= call.response.status %>

				<%= render "_http_body.html", body: call.response.body %>
				<%= render "_http_headers.html", headers: call.response.headers %>

<%= end %>

<%= for call <- @stub_url.calls do %>

    <div class="panel-heading" role="tab" id="call-<%= call.id %>-heading">

        <a role="button" data-toggle="collapse" data-parent="#accordion" href="#call-<%= call.id %>" aria-expanded="true" aria-controls="collapseOne">
			<span data-time="<%= call.inserted_at |> Ecto.DateTime.to_iso8601 %>"><%= call.inserted_at |> Ecto.DateTime.to_iso8601%> |
			 <%= call.request.method %>  <%= call.request.url %>
			<%= call.response.status %>

    <div id="call-<%= call.id %>" class="panel-collapse collapse" role="tabpanel" aria-labelledby="call-<%= call.id %>-heading">

		    	<a href="#call-<%= call.id %>-request" aria-controls="call-<%= call.id %>-request" role="tab" data-toggle="tab">Request

		    	<a href="#call-<%= call.id %>-response" aria-controls="call-<%= call.id %>-response" role="tab" data-toggle="tab">Response

		    <div role="tabpanel" class="tab-pane active" id="call-<%= call.id %>-request">
				<%= render "_http_body.html", body: call.request.body %>
				<%= render "_http_headers.html", headers: call.request.headers %>

		    <div role="tabpanel" class="tab-pane" id="call-<%= call.id %>-response">

Status: <%= call.response.status %>

				<%= render "_http_body.html", body: call.response.body %>
				<%= render "_http_headers.html", headers: call.response.headers %>

<%= end %>


css fixes

css fixes

Transaction Information

  <span class="fa <%= get_icon(@transaction.type) %>">
  <%= get_type(@transaction.type) %>
  | Hash:
  <%= @transaction.txid %>

<a href="<%= transactions_path(@conn, :index) %>" alt="Back to all transactions" title="Back to all transactions" class="back-link"><%= gettext "Back to all transactions" %>

      <%= if @transaction.type == "ClaimTransaction" do %>

<%= gettext "Claimed from" %>

        <%= for input <- @transaction.claims do %>

            <a href="<%= address_path(@conn, :index, input.address_hash)%>" alt="View wallet address" title="View wallet address" class="large-blue-link wallet-address"><%= input.address_hash %>

<%= Helpers.round_or_not(input.value) %> <%= Api.get_asset_name(input.asset) %>

        <% end %>
      <% end %>
      <%= if @transaction.type != "ClaimTransaction" and @transaction.vin != []  do %>

<%= gettext "Sent from" %>

        <%= for input <- @transaction.vin do %>

    				<a href="<%= address_path(@conn, :index, input.address_hash)%>" alt="View wallet address" title="View wallet address" class="large-blue-link wallet-address"><%= input.address_hash %>

<%= Helpers.round_or_not(input.value) %> <%= Api.get_asset_name(input.asset) %>

        <% end %>
      <% end %>

		<img src="<%= static_path(@conn, "/images/ICON_Sent-arrow.svg")%>" alt="Sent arrow" title="Sent arrow" class="transaction-sent-arrow" />

      <%= if @transaction.vouts != [] do %>

<%= gettext "Sent to" %>

        <%= for vout <- @transaction.vouts do %>

    				<a href="<%= address_path(@conn, :index, vout.address_hash)%>" alt="View wallet address" title="View wallet address" class="large-blue-link wallet-address"><%= vout.address_hash %>

<%= Helpers.round_or_not(vout.value) %> <%= Api.get_asset_name(vout.asset) %>

        <% end %>
      <% end %>
      <%= if @transaction.type == "RegisterTransaction" do %>

<%= gettext "Registered" %>

          <a href="<%= address_path(@conn, :index, @transaction.asset.admin)%>" alt="View wallet address" title="View wallet address" class="large-blue-link wallet-address"><%= @transaction.asset.admin %>

<%= Helpers.round_or_not(@transaction.asset.amount) %> <%= Api.get_asset_name(@transaction.txid) %>

      <% end %>

<%= gettext "Time" %>

<%= compare_time_and_get_minutes(@transaction.time) %>

      <%= get_explanation("transaction_time") %>

<%= gettext "Network Fee" %>

<%= @transaction.net_fee %>

      <%= get_explanation("transaction_network_fees") %>

<%= gettext "System Fee" %>

<%= @transaction.sys_fee %>

      <%= get_explanation("transaction_system_fees") %>

<%= gettext "Included in Block" %>

<a href="<%= block_path( @conn, :index, @transaction.block_hash) %>" alt="View transaction" title="View transaction" class="large-blue-link col-4-width"><%= @transaction.block_height %>

<%= gettext "Size" %>

<%= @transaction.size %> <%= gettext "bytes" %>

      <%= get_explanation("transaction_size") %>

<%= gettext "Bytecode Invocation Script" %>

      <%= get_explanation("bytecode_invocation_script") %>

			<%= for script <- @transaction.scripts do %>

<%= get_inv(script) %>

			<% end %>

<%= gettext "Bytecode Verification Script" %>

      <%= get_explanation("bytecode_verification_script") %>

			<%= for script <- @transaction.scripts do %>

<%= get_ver(script) %>

			<% end %>

  <%= if @transaction.attributes != [] do %>
		<%= for att <- @transaction.attributes do %>

<%= gettext "Usage: " %> <%=att["usage"]%>

<%= att["data"] %>

		<% end %>
  <% end %>
  <%= if @transaction.script != nil do %>

<%= gettext "Bytecode Script" %>

<%= @transaction.script %>

  <% end %>

<%= gettext "Opcode Invocation Script" %>

      <%= get_explanation("opcode_invocation_script") %>

        <%= for script <- @transaction.scripts do %>
          <%= for operation <- parse_invocation(script) do %>
            <%= operation %>
          <% end %>
        <% end %>

<%= gettext "Opcode Verification Script" %>

      <%= get_explanation("opcode_verification_script") %>

        <%= for script <- @transaction.scripts do %>
          <%= for operation <- parse_verification(script) do %>
            <%= operation %>
          <% end %>
        <% end %>

  <%= if @transaction.attributes != [] do %>
		<%= for att <- @transaction.attributes do %>

<%= gettext "Opcode Attribute:" %> <%=att["usage"]%>

<%= Disassembler.parse_script(att["data"]) %>

		<% end %>
  <% end %>
  <%= if @transaction.script != nil do %>

<%= gettext "Opcode Script" %>

<%= Disassembler.parse_script(@transaction.script) %>

  <% end %>


Link to github from about page. Fix #101

This project proposes an alternative to <%= link "github's trending page", to: "https://www.github.com/trending" %>, by exposing projects with high contribution rate, instead of daily stars (similarly to github's pulse page).
The krihelimeter of each repository is calculated using the number of authors, commits, pull requests, and issues of that project, from the past week.

    Krihelimeter =
    20
     * authors

    8
     * merged and proposed pull requests

    8
     * new and closed issues

    1
     * commits

During the development of this project I found out that people use github as a backup service, automating hundreds of commits per week.
Therefor, to filter these projects out, only projects with more than one author enters the Krihelinator DB.

Want to know more?

The Krihelinator is an <%= link "open source project", to: "https://www.github.com/Nagasaki45/krihelinator" %> written in <%= link "elixir", to: "http://elixir-lang.org/" %>.
Contributions, of any kind, are more than welcome and highly appreciated :-).


testing

testing

<%= gettext "Welcome to %{name}", name: "Phoenix!" %>

A productive web framework that
does not compromise speed and maintainability.

          @
          <input id="username" type="text" class="form-control" placeholder="username">

      <input id="chat-input" type="text" style="width: 100%"></input>

Resources

        Guides

        Docs

        Source

<%= gettext "Welcome to %{name}", name: "Phoenix!" %>

A productive web framework that
does not compromise speed and maintainability.

<input id="chat-input" type="text" style="width: 100%"></input>

Resources

        Guides

        Docs

        Source