Skip to content
This repository has been archived by the owner on Oct 3, 2022. It is now read-only.

Commit

Permalink
Merge branch 'dev/webp-thumbnails'
Browse files Browse the repository at this point in the history
close #930
  • Loading branch information
bakape committed Feb 6, 2019
2 parents 45d44ba + 520577c commit cc941b8
Show file tree
Hide file tree
Showing 49 changed files with 1,354 additions and 1,313 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ www/lang
www/videos
thumb_*.png
thumb_*.jpg
thumb_*.webp
scripts/migration/3to4/3to4
/server/pkg
/server/bin
Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ compiled with:
* libtheora
* libx264
* libmp3lame
* GraphicsMagick compiled with:
* zlib
* libpng
* libjpeg
* OpenCV >= 2
* git

Expand Down
3 changes: 1 addition & 2 deletions client/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ export type BoardData = {

// Image data embeddable in posts and thread hashes
export interface ImageData {
apng: boolean
audio: boolean
video: boolean
spoiler: boolean
Expand All @@ -125,5 +124,5 @@ export interface ImageData {
// Possible file types of a post image
export enum fileTypes {
jpg, png, gif, webm, pdf, svg, mp4, mp3, ogg, zip, "7z", "tar.gz", "tar.xz",
flac, noFile, txt
flac, noFile, txt, webp,
}
2 changes: 0 additions & 2 deletions client/options/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,6 @@ function toggleAutoGIF() {
switch (image.fileType) {
case fileTypes.gif:
return true
case fileTypes.png:
return image.apng
default:
return false
}
Expand Down
12 changes: 2 additions & 10 deletions client/posts/images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default class ImageHandler extends View<Post> {
// Render the actual thumbnail image
private renderThumbnail() {
const el = this.el.querySelector("figure a"),
{ SHA1, fileType, thumbType, dims, spoiler, apng } = this
{ SHA1, fileType, thumbType, dims, spoiler } = this
.model
.image,
src = sourcePath(SHA1, fileType)
Expand All @@ -98,12 +98,7 @@ export default class ImageHandler extends View<Post> {
// Spoilered and spoilers enabled
thumb = '/assets/spoil/default.jpg'
thumbHeight = thumbWidth = 150
} else if (options.autogif
&& (
fileType === fileTypes.gif
|| (fileType === fileTypes.png && apng)
)
) {
} else if (options.autogif && fileType === fileTypes.gif) {
// Animated GIF thumbnails
thumb = src
} else {
Expand Down Expand Up @@ -161,9 +156,6 @@ export default class ImageHandler extends View<Post> {
el.textContent = s
}
break
case "is-apng":
el.hidden = !data.apng
break
case "filesize":
const { size } = data
let s: string
Expand Down
4 changes: 0 additions & 4 deletions client_cpp/src/posts/image.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,6 @@ Node PostView::render_file_info()
<< img.length % 60;
}
}
if (img.apng) {
COMMA
s << "APNG";
}

// Readable file size
COMMA
Expand Down
5 changes: 2 additions & 3 deletions client_cpp/src/posts/models.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ using std::string;

Image::Image(nlohmann::json& j)
{
PARSE_OPT(apng);
PARSE_OPT(audio);
PARSE_OPT(video);
PARSE_OPT(spoiler);
Expand Down Expand Up @@ -166,10 +165,10 @@ void Post::propagate_links()

// TODO: Notify about replies, if this post links to one of the user's posts

for (auto && [ id, _ ] : links) {
for (auto&& [id, _] : links) {
if (posts.count(id)) {
auto& target = posts.at(id);
target.backlinks[this->id] = LinkData{ false, op, board };
target.backlinks[this->id] = LinkData { false, op, board };
target.patch();
}
if (post_ids.hidden.count(id)) {
Expand Down
3 changes: 1 addition & 2 deletions client_cpp/src/posts/models.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ const static std::unordered_map<FileType, std::string> file_extentions = {
};

struct Image {
bool apng = false, // PNG image is APNG
audio = false, // Has audio
bool audio = false, // Has audio
video = false, // Has video
spoiler = false; // Is spoilered
FileType file_type, // File type of source file
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ All commands assume to be run by the root user.
```bash
# Install C dependencies
apt-get update
apt-get install -y build-essential pkg-config libpth-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libgraphicsmagick1-dev libopencv-dev git
apt-get install -y build-essential pkg-config libpth-dev libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libwebp-dev libopencv-dev git
apt-get dist-upgrade -y

# Install Node.js
Expand Down
6 changes: 1 addition & 5 deletions lang/en_GB/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Information panel text",
"Entries for the banner's Frequently Asked Questions list and information modal"
],
"JPEGQuality": [
"JPEG thumbnail quality",
"Quality of image JPEG thumbnails"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
6 changes: 1 addition & 5 deletions lang/es_ES/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Information panel text",
"Entries for the banner's Frequently Asked Questions list and information modal"
],
"JPEGQuality": [
"JPEG thumbnail quality",
"Quality of image JPEG thumbnails"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
6 changes: 1 addition & 5 deletions lang/fr_FR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Panneau d'information",
"Message à afficher dans la Foire Aux Questions"
],
"JPEGQuality": [
"Qualité des vignettes JPEG",
"Règle la qualité des JPEG miniaturisés"
],
"NSFW": [
"NSFW",
"Cette planche autorise du contenu qui n'est pas recommandé dans un environnement de travail"
Expand Down Expand Up @@ -496,4 +492,4 @@
"type": "Type",
"unban": "Gracier"
}
}
}
6 changes: 1 addition & 5 deletions lang/pl_PL/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Panel informacyjny",
"Wpisy związane z najczęściej zadawanymi pytaniami i innymi informacjami"
],
"JPEGQuality": [
"Jakość miniatur JPEG",
"Określ poziom jakości miniatur JPEG"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
6 changes: 1 addition & 5 deletions lang/pt_BR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Information panel text",
"Entries for the banner's Frequently Asked Questions list and information modal"
],
"JPEGQuality": [
"JPEG thumbnail quality",
"Quality of image JPEG thumbnails"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
6 changes: 1 addition & 5 deletions lang/ru_RU/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"FAQ",
"Текст FAQ"
],
"JPEGQuality": [
"Качество превью",
"JPEG-качество превью изображений"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Тип",
"unban": "Разбанить"
}
}
}
6 changes: 1 addition & 5 deletions lang/sk_SK/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Information panel text",
"Entries for the banner's Frequently Asked Questions list and information modal"
],
"JPEGQuality": [
"JPEG kompresia náhľadu",
"Kvalita JPEG náhľadov"
],
"NSFW": [
"Nevhodné do práce",
"Doska povoľuje materiál, ktorý nie je bezpečné prezerať v pracovnom prostredí"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Typ",
"unban": "Odbanuj"
}
}
}
6 changes: 1 addition & 5 deletions lang/tr_TR/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Information panel text",
"Entries for the banner's Frequently Asked Questions list and information modal"
],
"JPEGQuality": [
"JPEG thumbnail quality",
"Quality of image JPEG thumbnails"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
6 changes: 1 addition & 5 deletions lang/uk_UA/server.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
"Інформаційни блок тексту",
"Записи для баннеру списку ФАК та інформаційни модальних вікон"
],
"JPEGQuality": [
"Якість JPEG ",
"Якість для пре JPEG превюшок"
],
"NSFW": [
"Not Safe For Work",
"Board allows material, that are not safe to be viewed in a work environment"
Expand Down Expand Up @@ -498,4 +494,4 @@
"type": "Type",
"unban": "Unban"
}
}
}
3 changes: 2 additions & 1 deletion server/src/meguca/common/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ const (
FLAC
NoFile
TXT
WEBP
)

// Extensions maps internal file types to their canonical file extensions
var Extensions = map[uint8]string{
JPEG: "jpg",
PNG: "png",
GIF: "gif",
WEBP: "webp",
MP3: "mp3",
MP4: "mp4",
WEBM: "webm",
Expand All @@ -48,7 +50,6 @@ type Image struct {
// ImageCommon contains the common data shared between multiple post referencing
// the same image
type ImageCommon struct {
APNG bool `json:"apng,omitempty"`
Audio bool `json:"audio,omitempty"`
// Only used for file formats like OGG and MP4 that may or may not contain
// video
Expand Down
1 change: 0 additions & 1 deletion server/src/meguca/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ var (
// Defaults contains the default server configuration values
Defaults = Configs{
BoardExpiry: 7,
JPEGQuality: 90,
MaxHeight: 6000,
MaxWidth: 6000,
SessionExpiry: 30,
Expand Down
7 changes: 3 additions & 4 deletions server/src/meguca/config/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ package config
// Configs stores the global server configuration
type Configs struct {
Public
PruneBoards bool `json:"pruneBoards"`
HideNSFW bool `json:"hideNSFW"`
EmailErr bool `json:"emailErr"`
JPEGQuality uint8
PruneBoards bool `json:"pruneBoards"`
HideNSFW bool `json:"hideNSFW"`
EmailErr bool `json:"emailErr"`
MaxWidth uint16 `json:"maxWidth"`
MaxHeight uint16 `json:"maxHeight"`
BoardExpiry uint `json:"boardExpiry"`
Expand Down
13 changes: 8 additions & 5 deletions server/src/meguca/db/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package db
import (
"database/sql"
"errors"
"io"
"meguca/auth"
"meguca/common"
"meguca/imager/assets"
Expand Down Expand Up @@ -43,11 +44,11 @@ func writeImageTx(tx *sql.Tx, i common.ImageCommon) (err error) {
err = withTransaction(tx, sq.
Insert("images").
Columns(
"apng", "audio", "video", "fileType", "thumbType", "dims", "length",
"audio", "video", "fileType", "thumbType", "dims", "length",
"size", "MD5", "SHA1", "Title", "Artist",
).
Values(
i.APNG, i.Audio, i.Video, int(i.FileType), int(i.ThumbType),
i.Audio, i.Video, int(i.FileType), int(i.ThumbType),
pq.GenericArray{A: i.Dims}, i.Length, i.Size, i.MD5, i.SHA1,
i.Title, i.Artist,
)).
Expand Down Expand Up @@ -140,9 +141,11 @@ func UseImageToken(tx *sql.Tx, token string) (

// AllocateImage allocates an image's file resources to their respective served
// directories and write its data to the database
func AllocateImage(tx *sql.Tx, src, thumb []byte, img common.ImageCommon,
) error {
err := writeImageTx(tx, img)
func AllocateImage(tx *sql.Tx, src, thumb io.ReadSeeker, img common.ImageCommon,
) (
err error,
) {
err = writeImageTx(tx, img)
if err != nil {
return err
}
Expand Down
Loading

0 comments on commit cc941b8

Please sign in to comment.