module

Ktistec::Constants

Constants

ACCEPT_HEADER = "application/activity+json, application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
CONTENT_TYPE_HEADER = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""
HTML_PARSER_OPTIONS = ((((XML::HTMLParserOptions::RECOVER | XML::HTMLParserOptions::NODEFDTD) | XML::HTMLParserOptions::NOIMPLIED) | XML::HTMLParserOptions::NOERROR) | XML::HTMLParserOptions::NOWARNING) | XML::HTMLParserOptions::NONET

The options used when parsing content. NONET in particular keeps the parser from fetching anything the content references.

IMAGE_SIZE_LIMIT = 10485760

Maximum image upload size in bytes (10 MB)

LANGUAGE_RE = /^[a-zA-Z]{2,3}(-[a-zA-Z0-9]+)*$/
MAX_ATTACHMENT_CHARACTERS = 1500

Maximum number of characters in an attachment description (alt text)

MAX_MEDIA_ATTACHMENTS = 4

Maximum number of media attachments per post

MAX_PINNED_POSTS = 5

Maximum number of posts a user can pin to their profile

MAX_POLL_EXPIRATION = 30.days.total_seconds.to_i

Maximum poll expiration time in seconds

MAX_POLL_OPTION_CHARACTERS = 50

Maximum number of characters per poll option

MAX_POLL_OPTIONS = 4

Maximum number of options in a poll

MAX_POST_CHARACTERS = 5000

Maximum number of characters in a post

MIN_POLL_EXPIRATION = 5.minutes.total_seconds.to_i

Minimum poll expiration time in seconds

PUBLIC = "https://www.w3.org/ns/activitystreams#Public"
SUPPORTED_AUDIO_TYPES = SUPPORTED_MEDIA_TYPES_TABLE.select do |e| e[:category] == (:audio) end.map do |e| e[:mime] end
SUPPORTED_IMAGE_TYPES = SUPPORTED_MEDIA_TYPES_TABLE.select do |e| e[:category] == (:image) end.map do |e| e[:mime] end
SUPPORTED_MEDIA_TYPES = SUPPORTED_MEDIA_TYPES_TABLE.map do |e| e[:mime] end
SUPPORTED_MEDIA_TYPES_MAP = SUPPORTED_MEDIA_TYPES_TABLE.each_with_object({} of String => String) do |e, map| e[:extensions].each do |ext| __temp_df88a532_1 = ext map[__temp_df88a532_1]? || (map[__temp_df88a532_1] = e[:mime]) end end

Maps a lowercase filename extension to its canonical media type.

SUPPORTED_MEDIA_TYPES_TABLE = [{mime: "image/apng", category: :image, extensions: [".apng"] of ::String}, {mime: "image/avif", category: :image, extensions: [".avif"] of ::String}, {mime: "image/bmp", category: :image, extensions: [".bmp"] of ::String}, {mime: "image/gif", category: :image, extensions: [".gif"] of ::String}, {mime: "image/jpeg", category: :image, extensions: [".jpeg", ".jpg"] of ::String}, {mime: "image/png", category: :image, extensions: [".png"] of ::String}, {mime: "image/svg+xml", category: :image, extensions: [".svg"] of ::String}, {mime: "image/webp", category: :image, extensions: [".webp"] of ::String}, {mime: "image/x-icon", category: :image, extensions: [".ico"] of ::String}, {mime: "video/mp4", category: :video, extensions: [".mp4"] of ::String}, {mime: "video/ogg", category: :video, extensions: [".ogv"] of ::String}, {mime: "video/quicktime", category: :video, extensions: [".mov"] of ::String}, {mime: "video/webm", category: :video, extensions: [".webm"] of ::String}, {mime: "video/x-m4v", category: :video, extensions: [".m4v"] of ::String}, {mime: "audio/flac", category: :audio, extensions: [".flac"] of ::String}, {mime: "audio/mp4", category: :audio, extensions: [".m4a"] of ::String}, {mime: "audio/mpeg", category: :audio, extensions: [".mp3"] of ::String}, {mime: "audio/ogg", category: :audio, extensions: [".oga", ".ogg"] of ::String}, {mime: "audio/wav", category: :audio, extensions: [".wav"] of ::String}, {mime: "audio/webm", category: :audio, extensions: [".webm"] of ::String}]

Authoritative table of supported media types.

SUPPORTED_UPLOAD_EXTENSIONS = SUPPORTED_MEDIA_TYPES_TABLE.flat_map do |e| e[:extensions] end.uniq!
SUPPORTED_VIDEO_TYPES = SUPPORTED_MEDIA_TYPES_TABLE.select do |e| e[:category] == (:video) end.map do |e| e[:mime] end
XRD_ENV = "<?xml version='1.0'?>\n<XRD\n xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'\n xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>\n%s\n</XRD>"

XRD document wrapper used by HostMeta and WebFinger. The body is interpolated into the wrapper (e.g. XRD_ENV % "<Link .../>").