Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ku1ik committed Dec 16, 2023
2 parents 9dcbba9 + b31ab70 commit 5ac82dc
Show file tree
Hide file tree
Showing 31 changed files with 373 additions and 93 deletions.
2 changes: 1 addition & 1 deletion .env.production.sample
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ URL_HOST=localhost
URL_PORT=3000

## Base secret key for signing cookies etc.
## Run `docker-compose run --rm phoenix gen_secret`
## Run `docker run --rm ghcr.io/asciinema/asciinema-server gen_secret`
## and copy generated secret here.
SECRET_KEY_BASE=

Expand Down
4 changes: 1 addition & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,11 @@ RUN chgrp -R 0 /opt/app && chmod -R g=u /opt/app
COPY .iex.exs .

ENV PORT 4000
ENV ADMIN_BIND_ALL 1
ENV DATABASE_URL "postgresql://postgres@postgres/postgres"
ENV RSVG_FONT_FAMILY "Dejavu Sans Mono"
ENV PATH "/opt/app/bin:${PATH}"

VOLUME /opt/app/uploads
VOLUME /opt/app/cache

ENTRYPOINT ["/sbin/tini", "--"]
CMD ["/opt/app/bin/server"]

Expand Down
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ at [asciinema/asciinema](https://github.com/asciinema/asciinema), and the source
code of asciinema web player
at [asciinema/asciinema-player](https://github.com/asciinema/asciinema-player).

Shout-out to our Platinum [sponsors](https://github.com/sponsors/ku1ik), whose
financial support helps keep the project alive:

[<img src="./assets/static/images/sponsor-logos/dashcam/logo-on-light.png" width="200" />](https://dashcam.io?utm_source=asciinemagithub)

## Setting up your own asciinema web app instance

asciinema terminal recorder uses [asciinema.org](https://asciinema.org) as its
Expand Down Expand Up @@ -48,9 +43,6 @@ read on

## Sponsors

asciinema is sponsored by:

- [**Dashcam**](https://dashcam.io?utm_source=asciinemagithub)
- [Brightbox](https://www.brightbox.com/)

## Consulting
Expand Down
10 changes: 9 additions & 1 deletion assets/css/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ body, main {
background-color: #f7f7f7;
}

.c-recording, .c-live-stream {
.c-page, .c-recording, .c-live-stream {
main {
h1, h2, h3 {
margin-top: 2rem;
Expand All @@ -87,6 +87,10 @@ body, main {
}
}

.c-page .container > h1 {
margin-bottom: 2rem;
}

section.cinema {
color: #fff;
background-color: #222;
Expand Down Expand Up @@ -202,3 +206,7 @@ body pre {
background-color: #eee;
border-color: #ccc;
}

span.email b {
display: none;
}
61 changes: 38 additions & 23 deletions assets/static/js/embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,54 @@
}

function params(container, script) {
function format(name) {
var value = script.getAttribute('data-' + name);
if (value) {
return name + '=' + value;
}
if (script.dataset.t !== undefined) {
script.dataset.startAt = script.dataset.t;
}

if (script.dataset.i !== undefined) {
script.dataset.idleTimeLimit = script.dataset.i;
}

var options = ['size', 'speed', 'autoplay', 'loop', 'theme', 't', 'startAt', 'preload', 'cols', 'rows', 'i', 'idleTimeLimit'];
if (script.dataset.autoplay === '') {
script.dataset.autoplay = '1';
}

if (script.dataset.loop === '') {
script.dataset.loop = '1';
}

return '?' + options.map(format).filter(Boolean).join('&');
if (script.dataset.preload === '') {
script.dataset.preload = '1';
}

const keys = new Set(['speed', 'autoplay', 'loop', 'theme', 'startAt', 'preload', 'cols', 'rows', 'idleTimeLimit', 'poster']);

return Object.entries(script.dataset)
.filter(([key, _]) => keys.has(key))
.map(kv => kv.join('='))
.join('&');
}

function locationFromString(string) {
var parser = document.createElement('a');
const parser = document.createElement('a');
parser.href = string;
return parser;
}

function apiHostFromScript(script) {
var location = locationFromString(script.src);
const 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) {
if (script.dataset.initialized !== undefined) {
return;
}

var apiHost = apiHostFromScript(script);
const apiHost = apiHostFromScript(script);
const asciicastId = script.id.split('-')[1];
const container = document.createElement('div');

var asciicastId = script.id.split('-')[1];

var container = document.createElement('div');
container.id = "asciicast-container-" + asciicastId;
container.className = 'asciicast';
container.style.display = 'block';
Expand All @@ -50,8 +64,8 @@

insertAfter(script, container);

var iframe = document.createElement('iframe');
iframe.src = apiHost + "/a/" + asciicastId + '/iframe' + params(container, script);
const iframe = document.createElement('iframe');
iframe.src = apiHost + "/a/" + asciicastId + '/iframe?' + params(container, script);
iframe.id = "asciicast-iframe-" + asciicastId;
iframe.name = "asciicast-iframe-" + asciicastId;
iframe.scrolling = "no";
Expand All @@ -68,19 +82,20 @@
container.appendChild(iframe);

function receiveSize(e) {
var name = e.data[0];
var data = e.data[1];
const name = e.data[0];
const data = e.data[1];

if (e.origin === apiHost && e.source === iframe.contentWindow && name === 'resize') {
iframe.style.height = '' + data.height + 'px';
}
}

window.addEventListener("message", receiveSize, false);

script.dataset.player = container;
script.dataset.initialized = '1';
}

var scripts = document.querySelectorAll("script[id^='asciicast-']");
[].forEach.call(scripts, insertPlayer);
[].forEach.call(
document.querySelectorAll("script[id^='asciicast-']"),
insertPlayer
);
})();
10 changes: 9 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ config :asciinema,

config :asciinema, Asciinema.Repo, migration_timestamps: [type: :naive_datetime_usec]

# Configures the endpoint
# Configures the public endpoint
config :asciinema, AsciinemaWeb.Endpoint,
url: [host: "localhost"],
render_errors: [view: AsciinemaWeb.ErrorView, accepts: ~w(html json), layout: false],
live_view: [signing_salt: "F3BMP7k9SZ-Y2SMJ"],
pubsub_server: Asciinema.PubSub

# Configures the admin endpoint
config :asciinema, AsciinemaWeb.Admin.Endpoint,
url: [host: "localhost"],
live_view: [signing_salt: "F3BMP7k9SZ-Y2SMJ"],
pubsub_server: Asciinema.PubSub

# Configures Elixir's Logger
config :logger, :console,
format: "$time $metadata[$level] $message\n",
Expand All @@ -45,6 +51,8 @@ config :asciinema, Asciinema.FileStore.Local, path: "uploads/"

config :asciinema, Asciinema.FileCache, path: "cache/"

config :asciinema, Asciinema.Emails.Mailer, adapter: Bamboo.LocalAdapter

config :asciinema, :png_generator, Asciinema.PngGenerator.Rsvg

config :asciinema, Asciinema.PngGenerator.Rsvg,
Expand Down
9 changes: 7 additions & 2 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ config :asciinema, AsciinemaWeb.Endpoint,
]
]

config :asciinema, AsciinemaWeb.Admin.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
check_origin: false,
code_reloader: true,
debug_errors: true,
secret_key_base: secret_key_base

config :asciinema, Asciinema.Accounts, secret: secret_key_base

# Watch static and templates for browser reloading.
Expand Down Expand Up @@ -65,8 +72,6 @@ config :phoenix, :stacktrace_depth, 20
# Initialize plugs at runtime for faster development compilation
config :phoenix, :plug_init_mode, :runtime

config :asciinema, Asciinema.Emails.Mailer, adapter: Bamboo.LocalAdapter

config :asciinema, Asciinema.Telemetry, enabled: false

# Import custom config.
Expand Down
12 changes: 6 additions & 6 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ config :asciinema, AsciinemaWeb.Endpoint,
],
cache_static_manifest: "priv/static/cache_manifest.json"

config :asciinema, AsciinemaWeb.Admin.Endpoint,
http: [ip: {127, 0, 0, 1}, port: 4002],
check_origin: false

# Do not print debug messages in production
config :logger, level: :info

config :asciinema, Asciinema.Repo,
pool_size: 20,
pool_size: 10,
ssl: false

config :asciinema, Asciinema.Emails.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "smtp",
port: 25

config :asciinema, Asciinema.FileStore.Local, path: "/var/opt/asciinema/uploads"
config :asciinema, Asciinema.FileCache, path: "/var/cache/asciinema"
Loading

0 comments on commit 5ac82dc

Please sign in to comment.