Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Version 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ShoyuVanilla committed May 25, 2020
1 parent 93ec519 commit 9e4c594
Show file tree
Hide file tree
Showing 15 changed files with 258 additions and 214 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10

name: Upload Release Asset

jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build project # This would actually build your project, using zip for an example artifact
run: |
zip -r release.zip module/
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./release.zip
asset_name: release.zip
asset_content_type: application/zip
Binary file added Preview.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Printable /stream

A Foundry Virtual Tabletop Module that makes /stream view suitable for web browser's print function.
A Foundry Virtual Tabletop Module that makes /stream view suitable for the web browser's print page function.

## How to use

![Priview Image](Preview.gif)

1. Install and activate this module.
2. Go to the \<your-hostname>/stream page or just click the **Print** button, which is next to the **Export Chat Log** button.
2. Go to the \<your-hostname>/stream page or just click the **Print** button, which is right above the chat textinput box.
3. Print the /stream view page with your web browser's print function.
10 changes: 0 additions & 10 deletions lang/en.json

This file was deleted.

10 changes: 0 additions & 10 deletions lang/ko-KR.json

This file was deleted.

29 changes: 0 additions & 29 deletions module.json

This file was deleted.

10 changes: 10 additions & 0 deletions module/lang/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printable-stream.electron-error-message": "Printable /stream cannot work within the standalone FVTT Application. Please open your game from a regular browser.",
"printable-stream.print-button": "Print",
"printable-stream.hide-buttons-s": "Hide Buttons",
"printable-stream.hide-buttons-l": "Hide buttons in chat messages in /stream view.",
"printable-stream.fitwidth-s": "Fit Width",
"printable-stream.fitwidth-l": "Fit chat messages' width to page width in /stream view.",
"printable-stream.bgcolor-s": "Background Color",
"printable-stream.bgcolor-l": "Set background color of /stream view. e.g. black, #FFFFFF"
}
10 changes: 10 additions & 0 deletions module/lang/ko.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"printable-stream.electron-error-message": "Printable /stream은 FVTT 스탠드얼론 어플리케이션에서 실행할 수 없습니다. 일반 웹 브라우저에서 사용하십시오.",
"printable-stream.print-button": "출력",
"printable-stream.hide-buttons-s": "버튼 숨기기",
"printable-stream.hide-buttons-l": "/stream 뷰에서 채팅 메시지에 있는 버튼을 숨깁니다.",
"printable-stream.fitwidth-s": "폭 맞춤",
"printable-stream.fitwidth-l": "/stream 뷰에서 채팅 메시지 가로 폭을 페이지에 맞춥니다.",
"printable-stream.bgcolor-s": "배경 색상",
"printable-stream.bgcolor-l": "/stream 뷰의 배경 색상을 지정합니다. 예시) black, #FFFFFF"
}
29 changes: 29 additions & 0 deletions module/module.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "PrintableStream",
"title": "Printable /stream",
"description": "Make /stream view suitable for web browser's printing function.",
"version": "0.3.3",
"minimumCoreVersion" : "0.5.5",
"compatibleCoreVersion": "0.6.0",
"author": "Shoyu Vanilla",

"scripts": ["printable-stream.js"],
"styles": ["style.css"],

"languages": [
{
"lang": "en",
"name": "English",
"path": "lang/en.json"
},
{
"lang": "ko",
"name": "한국어 (Korean)",
"path": "lang/ko.json"
}
],

"url": "https://github.com/ShoyuVanilla/FoundryVTT-Printable-Stream",
"manifest": "https://raw.githubusercontent.com/ShoyuVanilla/FoundryVTT-Printable-Stream/master/module/module.json",
"download": "https://github.com/ShoyuVanilla/FoundryVTT-Printable-Stream/releases/download/v0.3.3/release.zip"
}
34 changes: 34 additions & 0 deletions module/printable-stream.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
* {
-webkit-touch-callout: all; /* iOS Safari */
-webkit-user-select: all; /* Safari */
-khtml-user-select: all; /* Konqueror HTML */
-moz-user-select: all; /* Firefox */
-ms-user-select: all; /* Internet Explorer/Edge */
user-select: all; /* Non-prefixed version */
}
body.stream {
overflow: visible;
height: auto;
}
body.stream #chat {
left: 0px;
}
body.stream .tab[data-tab] {
top: 0px;
}
.sidebar-tab {
overflow: visible;
}
#chat-log {
overflow: visible;
}

@media print
{
#chat-log .message {
page-break-inside: avoid;
}
.message-metadata .button {
display: none;
}
}
126 changes: 126 additions & 0 deletions module/printable-stream.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
class PrintableStreamModule {
static onRenderChatLog(chatLog, html, data) {
let element = document.getElementById("chat-controls");
if (!element) return;
let printButtonTitle = window.game.i18n.localize("printable-stream.print-button");
let printButton = document.createElement("a");
printButton.className = "printable-stream-button";
printButton.setAttribute("title", printButtonTitle);
printButton.innerHTML = '<i class="fas fa-print"></i>'
printButton.onclick = () => PrintableStreamModule.onPrintButtonClicked();
element.insertBefore(printButton, document.getElementsByClassName("roll-type-select")[0].nextSibling);
}

static onRenderChatMessage(chatMessage, html, messageData) {
// Set message timeStamp as dateTime on which the message has been written
const lang = navigator.language || navigator.userLanguage;
const time = new Date(messageData.message.timestamp).toLocaleDateString(lang, {
hour: "numeric",
minute: "numeric",
second: "numeric"
});
let element = html.find(".message-timestamp")[0];
element.innerText = time;
}

static onPrintButtonClicked() {
if (navigator.userAgent.toLowerCase().indexOf(" electron/") !== -1) {
let errorMessage = window.game.i18n.localize("printable-stream.electron-error-message");
return ui.notifications.warn(errorMessage);
}

window.open('/stream', '_blank');
}

static addStyle(styleString) {
const style = document.createElement('style');
style.textContent = styleString;
document.head.append(style);
}
}

// Settings
Hooks.once('init', () => {
game.settings.register('PrintableStream', 'hideButtons', {
name: "printable-stream.hide-buttons-s",
hint: "printable-stream.hide-buttons-l",
scope: "client",
config: true,
default: false,
type: Boolean
});

game.settings.register('PrintableStream', 'fitwidth', {
name: "printable-stream.fitwidth-s",
hint: "printable-stream.fitwidth-l",
scope: "client",
config: true,
default: true,
type: Boolean
});

game.settings.register('PrintableStream', 'bgColor', {
name: "printable-stream.bgcolor-s",
hint: "printable-stream.bgcolor-l",
scope: "client",
config: true,
default: "transparent",
type: String,
});
});

Hooks.once('init', () => {
const url = window.location.pathname;
if (/\/stream/.test(url)) {
// Increase ChatMessage batch size to render all messages
CONFIG.ChatMessage.batchSize = Number.MAX_SAFE_INTEGER;

// Inject css
let cssId = 'modules/PrintableStream/printable-stream.css';
if (!document.getElementById(cssId)) {
let head = document.getElementsByTagName('head')[0];
let link = document.createElement('link');
link.id = cssId;
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = cssId;
link.media = 'all';
head.appendChild(link);
}

// Disable updateTimestamps
ChatLog.prototype.updateTimestamps = () => {};

// renderChatMessage Hook
Hooks.on('renderChatMessage', PrintableStreamModule.onRenderChatMessage);

// Apply settings
const hideButtons = game.settings.get('PrintableStream', 'hideButtons');
const fitwidth = game.settings.get('PrintableStream', 'fitwidth');
const bgColor = game.settings.get('PrintableStream', 'bgColor');

if (hideButtons) {
PrintableStreamModule.addStyle(`
button {
display: none;
}
`);
}

if (fitwidth) {
PrintableStreamModule.addStyle(`
body.stream .tab[data-tab] {
width: 100%;
}
`);
}

PrintableStreamModule.addStyle(`
body.stream {
background: ${bgColor};
}
`);
}
});

Hooks.on('renderChatLog', PrintableStreamModule.onRenderChatLog);
7 changes: 7 additions & 0 deletions module/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#chat-controls div.roll-type-select select {
width: 176px;
}
.printable-stream-button {
flex: 0;
margin-right: 3px;
}
34 changes: 0 additions & 34 deletions printable-stream.css

This file was deleted.

Loading

0 comments on commit 9e4c594

Please sign in to comment.