Compare commits
16 Commits
improve-em
...
master
Author | SHA1 | Date |
---|---|---|
Marcin Kulik | 11554512e9 | 7 years ago |
Marcin Kulik | a9f443766e | 7 years ago |
Marcin Kulik | a96e8518bc | 7 years ago |
Marcin Kulik | 8c9e9f4c03 | 7 years ago |
Marcin Kulik | 39e6fb31c0 | 7 years ago |
Marcin Kulik | 0a195defe0 | 7 years ago |
Marcin Kulik | c25820677e | 7 years ago |
Marcin Kulik | 8e37e17ca1 | 7 years ago |
Marcin Kulik | 05d42b3f2f | 7 years ago |
Marcin Kulik | cc60d4e04b | 7 years ago |
Marcin Kulik | 426ed5ddda | 7 years ago |
Marcin Kulik | 857a45d310 | 7 years ago |
Marcin Kulik | 5f2e91356a | 7 years ago |
Marcin Kulik | ea8d1c9b40 | 7 years ago |
Marcin Kulik | f249d4a276 | 7 years ago |
Marcin Kulik | 3b798f61c9 | 7 years ago |
@ -1 +1,3 @@
|
||||
alias Asciinema.{Repo, Asciicasts, Asciicast, Users, User}
|
||||
alias Asciinema.{Repo, Asciicasts, Accounts}
|
||||
alias Asciinema.Asciicasts.Asciicast
|
||||
alias Asciinema.Accounts.{User, ApiToken}
|
||||
|
@ -1,90 +0,0 @@
|
||||
// asciinema embedded player
|
||||
|
||||
(function() {
|
||||
function insertAfter(referenceNode, newNode) {
|
||||
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
|
||||
}
|
||||
|
||||
function params(container, script) {
|
||||
function format(name) {
|
||||
var value = script.getAttribute('data-' + name);
|
||||
if (value) {
|
||||
return name + '=' + value;
|
||||
}
|
||||
}
|
||||
|
||||
var options = ['size', 'speed', 'autoplay', 'loop', 'theme', 't', 'preload', 'cols', 'rows'];
|
||||
|
||||
return '?' + options.map(format).filter(Boolean).join('&');
|
||||
}
|
||||
|
||||
function locationFromString(string) {
|
||||
var parser = document.createElement('a');
|
||||
parser.href = string;
|
||||
return parser;
|
||||
}
|
||||
|
||||
function apiHostFromScript(script) {
|
||||
var location = locationFromString(script.src);
|
||||
return location.protocol + '//' + location.host;
|
||||
}
|
||||
|
||||
function insertPlayer(script) {
|
||||
// do not insert player if there's one already associated with this script
|
||||
if (script.dataset.player) {
|
||||
return;
|
||||
}
|
||||
|
||||
var apiHost = apiHostFromScript(script);
|
||||
|
||||
var asciicastId = script.id.split('-')[1];
|
||||
|
||||
var container = document.createElement('div');
|
||||
container.id = "asciicast-container-" + asciicastId;
|
||||
container.className = 'asciicast';
|
||||
container.style.display = 'block';
|
||||
container.style.float = 'none';
|
||||
container.style.overflow = 'hidden';
|
||||
container.style.padding = 0;
|
||||
container.style.margin = '20px 0';
|
||||
|
||||
insertAfter(script, container);
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = apiHost + "/a/" + asciicastId + '/embed' + params(container, script);
|
||||
iframe.id = "asciicast-iframe-" + asciicastId;
|
||||
iframe.name = "asciicast-iframe-" + asciicastId;
|
||||
iframe.scrolling = "no";
|
||||
iframe.setAttribute('allowFullScreen', 'true');
|
||||
iframe.style.overflow = "hidden";
|
||||
iframe.style.margin = 0;
|
||||
iframe.style.border = 0;
|
||||
iframe.style.display = "inline-block";
|
||||
iframe.style.width = "100%";
|
||||
iframe.style.float = "none";
|
||||
iframe.style.visibility = "hidden";
|
||||
iframe.onload = function() { this.style.visibility = 'visible' };
|
||||
|
||||
container.appendChild(iframe);
|
||||
|
||||
function receiveSize(e) {
|
||||
if (e.origin === apiHost) {
|
||||
var name = e.data[0];
|
||||
var data = e.data[1];
|
||||
var iframeWindow = iframe.contentWindow || iframe;
|
||||
|
||||
if (e.source == iframeWindow && name == 'asciicast:size') {
|
||||
iframe.style.width = '' + data.width + 'px';
|
||||
iframe.style.height = '' + data.height + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveSize, false);
|
||||
|
||||
script.dataset.player = container;
|
||||
}
|
||||
|
||||
var scripts = document.querySelectorAll("script[id^='asciicast-']");
|
||||
[].forEach.call(scripts, insertPlayer);
|
||||
})();
|
@ -0,0 +1 @@
|
||||
../../../assets/static/js/embed.js
|
@ -0,0 +1 @@
|
||||
/node_modules
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 4.4 KiB After Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 768 B After Width: | Height: | Size: 768 B |
Before Width: | Height: | Size: 188 KiB After Width: | Height: | Size: 188 KiB |
Before Width: | Height: | Size: 731 B After Width: | Height: | Size: 731 B |
@ -0,0 +1,90 @@
|
||||
// asciinema embedded player
|
||||
|
||||
(function() {
|
||||
function insertAfter(referenceNode, newNode) {
|
||||
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
|
||||
}
|
||||
|
||||
function params(container, script) {
|
||||
function format(name) {
|
||||
var value = script.getAttribute('data-' + name);
|
||||
if (value) {
|
||||
return name + '=' + value;
|
||||
}
|
||||
}
|
||||
|
||||
var options = ['size', 'speed', 'autoplay', 'loop', 'theme', 't', 'preload', 'cols', 'rows'];
|
||||
|
||||
return '?' + options.map(format).filter(Boolean).join('&');
|
||||
}
|
||||
|
||||
function locationFromString(string) {
|
||||
var parser = document.createElement('a');
|
||||
parser.href = string;
|
||||
return parser;
|
||||
}
|
||||
|
||||
function apiHostFromScript(script) {
|
||||
var location = locationFromString(script.src);
|
||||
return location.protocol + '//' + location.host;
|
||||
}
|
||||
|
||||
function insertPlayer(script) {
|
||||
// do not insert player if there's one already associated with this script
|
||||
if (script.dataset.player) {
|
||||
return;
|
||||
}
|
||||
|
||||
var apiHost = apiHostFromScript(script);
|
||||
|
||||
var asciicastId = script.id.split('-')[1];
|
||||
|
||||
var container = document.createElement('div');
|
||||
container.id = "asciicast-container-" + asciicastId;
|
||||
container.className = 'asciicast';
|
||||
container.style.display = 'block';
|
||||
container.style.float = 'none';
|
||||
container.style.overflow = 'hidden';
|
||||
container.style.padding = 0;
|
||||
container.style.margin = '20px 0';
|
||||
|
||||
insertAfter(script, container);
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.src = apiHost + "/a/" + asciicastId + '/embed' + params(container, script);
|
||||
iframe.id = "asciicast-iframe-" + asciicastId;
|
||||
iframe.name = "asciicast-iframe-" + asciicastId;
|
||||
iframe.scrolling = "no";
|
||||
iframe.setAttribute('allowFullScreen', 'true');
|
||||
iframe.style.overflow = "hidden";
|
||||
iframe.style.margin = 0;
|
||||
iframe.style.border = 0;
|
||||
iframe.style.display = "inline-block";
|
||||
iframe.style.width = "100%";
|
||||
iframe.style.float = "none";
|
||||
iframe.style.visibility = "hidden";
|
||||
iframe.onload = function() { this.style.visibility = 'visible' };
|
||||
|
||||
container.appendChild(iframe);
|
||||
|
||||
function receiveSize(e) {
|
||||
if (e.origin === apiHost) {
|
||||
var name = e.data[0];
|
||||
var data = e.data[1];
|
||||
var iframeWindow = iframe.contentWindow || iframe;
|
||||
|
||||
if (e.source == iframeWindow && name == 'asciicast:size') {
|
||||
iframe.style.width = '' + data.width + 'px';
|
||||
iframe.style.height = '' + data.height + 'px';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("message", receiveSize, false);
|
||||
|
||||
script.dataset.player = container;
|
||||
}
|
||||
|
||||
var scripts = document.querySelectorAll("script[id^='asciicast-']");
|
||||
[].forEach.call(scripts, insertPlayer);
|
||||
})();
|
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 62 KiB |
@ -0,0 +1,6 @@
|
||||
class MakeEmailUnique < ActiveRecord::Migration
|
||||
def change
|
||||
remove_index :users, name: "index_users_on_email"
|
||||
add_index :users, :email, unique: true
|
||||
end
|
||||
end
|
@ -1,6 +1,8 @@
|
||||
defmodule Asciinema.Asciicast do
|
||||
use Asciinema.Web, :model
|
||||
alias Asciinema.{User, Asciicast}
|
||||
defmodule Asciinema.Asciicasts.Asciicast do
|
||||
use Ecto.Schema
|
||||
import Ecto.Changeset
|
||||
alias Asciinema.Accounts.User
|
||||
alias Asciinema.Asciicasts.Asciicast
|
||||
alias Asciinema.PngGenerator.PngParams
|
||||
|
||||
@default_png_scale 2
|
@ -1,5 +1,5 @@
|
||||
defmodule Asciinema.AsciicastAnimationController do
|
||||
use Asciinema.Web, :controller
|
||||
defmodule AsciinemaWeb.AsciicastAnimationController do
|
||||
use AsciinemaWeb, :controller
|
||||
alias Asciinema.Asciicasts
|
||||
|
||||
def show(conn, %{"id" => id}) do
|
@ -0,0 +1,14 @@
|
||||
defmodule AsciinemaWeb.AsciicastEmbedController do
|
||||
use AsciinemaWeb, :controller
|
||||
|
||||
@max_age 60
|
||||
|
||||
def show(conn, _params) do
|
||||
path = Application.app_dir(:asciinema, "priv/static/js/embed.js")
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("application/javascript")
|
||||
|> put_resp_header("cache-control", "public, max-age=#{@max_age}")
|
||||
|> send_file(200, path)
|
||||
end
|
||||
end
|
@ -1,6 +1,7 @@
|
||||
defmodule Asciinema.AsciicastFileController do
|
||||
use Asciinema.Web, :controller
|
||||
alias Asciinema.{Asciicasts, Asciicast}
|
||||
defmodule AsciinemaWeb.AsciicastFileController do
|
||||
use AsciinemaWeb, :controller
|
||||
alias Asciinema.Asciicasts
|
||||
alias Asciinema.Asciicasts.Asciicast
|
||||
|
||||
def show(conn, %{"id" => id} = params) do
|
||||
asciicast = Asciicasts.get_asciicast!(id)
|
@ -1,6 +1,6 @@
|
||||
defmodule Asciinema.DocController do
|
||||
use Asciinema.Web, :controller
|
||||
alias Asciinema.{DocView, ErrorView}
|
||||
defmodule AsciinemaWeb.DocController do
|
||||
use AsciinemaWeb, :controller
|
||||
alias AsciinemaWeb.{DocView, ErrorView}
|
||||
|
||||
@topics ["how-it-works", "getting-started", "installation", "usage", "config", "embedding", "faq"]
|
||||
|
@ -1,4 +1,4 @@
|
||||
defmodule Asciinema.Gettext do
|
||||
defmodule AsciinemaWeb.Gettext do
|
||||
@moduledoc """
|
||||
A module providing Internationalization with a gettext-based API.
|
||||
|
@ -1,4 +1,4 @@
|
||||
defmodule Asciinema.Rails.Flash do
|
||||
defmodule AsciinemaWeb.Rails.Flash do
|
||||
import Plug.Conn
|
||||
|
||||
def put_rails_flash(conn, key, value) do
|
@ -0,0 +1,10 @@
|
||||
<p>Hello,</p>
|
||||
|
||||
<p>Click the following link to log in to asciinema.org:</p>
|
||||
|
||||
<p><a href="<%= @login_url %>"><%= @login_url %></a></p>
|
||||
|
||||
<p>
|
||||
<br>
|
||||
If you did not initiate this request, just ignore this email. The request will expire shortly.
|
||||
</p>
|