Skip to content

Commit

Permalink
Faster video (ZcashFoundation#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
skyl authored Aug 9, 2023
1 parent ecd26dc commit 0ce4e25
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 5 deletions.
3 changes: 3 additions & 0 deletions k8s/free2z/backend-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ spec:
cdn:
enabled: true
cacheMode: "USE_ORIGIN_HEADERS"
# cacheMode: "CACHE_ALL_STATIC"
cachePolicy:
includeHost: true
includeProtocol: true
Expand All @@ -20,6 +21,8 @@ spec:
# ttl: 0
# - code: 502
# ttl: 0
requestCoalescing: true
# 86400
customResponseHeaders:
headers:
- "Strict-Transport-Security: max-age=63072000; includeSubDomains; preload"
Expand Down
3 changes: 3 additions & 0 deletions k8s/free2z/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ server {
proxy_buffers 8 16k;
proxy_buffer_size 32k;

proxy_hide_header Cache-Control;
proxy_hide_header Expires;

location = /robots.txt {
if ($http_host ~* ^(test|stage)\.) {
return 200 "User-agent: *\nDisallow: /";
Expand Down
2 changes: 1 addition & 1 deletion py/dj/apps/g12f/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, attrs=None):


class PageForm(ModelForm):
tags = TagField(widget=WideTagWidget)
tags = TagField(widget=WideTagWidget, required=False)

class Meta:
model = zPage
Expand Down
2 changes: 1 addition & 1 deletion py/dj/apps/g12f/models/zpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ class zPage(models.Model):

created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
publish_at = models.DateTimeField(null=True)
publish_at = models.DateTimeField(null=True, blank=True)

class Meta:
verbose_name = "zPage"
Expand Down
4 changes: 2 additions & 2 deletions py/dj/apps/uploads/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ class Meta:
]
read_only_fields = ["id", "created_at", "updated_at", "mime_type"]

def get_url(self, obj):
def get_url(self, obj: GenericFile):
# return f"https://test.free2give.xyz/uploadz/{obj.file.name}"
return f"/uploadz/{obj.file.name}"
return obj.get_url()

def get_name(self, obj):
return obj.file.name
Expand Down
20 changes: 19 additions & 1 deletion ts/react/free2z/src/components/MathMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { useStoreState } from "../state/persist"
import CodeCopyButton from "./CodeCopyButton";
import { ReactNode, useMemo } from "react";
import React from "react";
import ReactPlayer from "react-player";

interface MathMarkdownProps {
content: string
Expand Down Expand Up @@ -186,7 +187,24 @@ function MemoMarkdown(props: MathMarkdownProps) {
if (url.startsWith('/')) {
url = `https://${window.location.host}${url}`
}
return <IframelyComponent url={url} />
// TODO: custom player?
// Iframely player looks a bit more polished than ReactPlayer
// // Check if the URL ends with supported audio/video formats
// const isMediaUrl = /\.(mp4|mp3|ogg|wav|webm)$/i.test(url);

// if (isMediaUrl) {
// return <ReactPlayer
// url={url} controls={true}
// width="100%"
// // maxWidth="380px"
// style={{
// margin: "0 auto",
// maxWidth: "550px",
// }}
// />;
// } else {
return <IframelyComponent url={url} />;
// }
} else {
return (
// @ts-ignore
Expand Down

0 comments on commit 0ce4e25

Please sign in to comment.