Skip to content

Commit

Permalink
feat(EditorPage): cleanup char counting (#599)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Feb 18, 2024
1 parent 43ffe5e commit 26be6de
Show file tree
Hide file tree
Showing 8 changed files with 579 additions and 472 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/msys2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
with:
msystem: mingw64
update: true
install: git make zip wget mingw-w64-x86_64-meson mingw-w64-x86_64-gcc mingw-w64-x86_64-vala mingw-w64-x86_64-libsoup3 mingw-w64-x86_64-libxml2 mingw-w64-x86_64-gtksourceview5 mingw-w64-x86_64-webp-pixbuf-loader mingw-w64-x86_64-libadwaita mingw-w64-x86_64-libgee mingw-w64-x86_64-json-glib mingw-w64-x86_64-libsecret mingw-w64-x86_64-desktop-file-utils mingw-w64-x86_64-imagemagick
install: git make zip wget mingw-w64-x86_64-meson mingw-w64-x86_64-gcc mingw-w64-x86_64-vala mingw-w64-x86_64-libsoup3 mingw-w64-x86_64-libxml2 mingw-w64-x86_64-gtksourceview5 mingw-w64-x86_64-webp-pixbuf-loader mingw-w64-x86_64-libadwaita mingw-w64-x86_64-libgee mingw-w64-x86_64-json-glib mingw-w64-x86_64-libsecret mingw-w64-x86_64-desktop-file-utils mingw-w64-x86_64-imagemagick mingw-w64-x86_64-icu
- run: make windows
- uses: actions/upload-artifact@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ if host_machine.system() == 'windows'
add_project_arguments('-mwindows', language: 'c')
endif

add_project_arguments(['--vapidir=' + meson.project_source_root() / 'vapi'], language: 'vala')
add_project_arguments (
'-DGETTEXT_PACKAGE="@0@"'.format(meson.project_name()),
language: 'c'
Expand Down Expand Up @@ -105,6 +106,7 @@ final_deps = [
dependency('json-glib-1.0', version: '>=1.4.4'),
dependency('libxml-2.0'),
dependency('libsecret-1', required: true),
dependency('icu-uc'),
libspelling,
gtksourceview_dep,
libgtk_dep,
Expand Down
276 changes: 143 additions & 133 deletions src/API/Instance.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,162 +8,172 @@ public class Tuba.API.Instance : Entity {
public int64 max_toot_chars { get; set; default = 0; }
public API.Mastodon.Configuration.Polls? poll_limits { get; set; default = null; }
public int64 upload_limit { get; set; default = 0; }
public API.Pleroma.Instance? pleroma { get; set; default = null; }
public API.Pleroma.Instance? pleroma { get; set; default = null; }

public override Type deserialize_array_type (string prop) {
switch (prop) {
public override Type deserialize_array_type (string prop) {
switch (prop) {
case "languages":
return Type.STRING;
}

return base.deserialize_array_type (prop);
}

public bool supports_quote_posting {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.features != null) {
return "quote_posting" in pleroma.metadata.features;
}

return false;
}
}

public string[]? compat_supported_mime_types {
get {
if (pleroma != null && pleroma.metadata != null) {
return pleroma.metadata.post_formats;
}

return configuration?.statuses?.supported_mime_types;
}
}

public int64 compat_fields_limits_max_fields {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.max_fields;
}

return 4;
}
}

public int64 compat_fields_limits_name_length {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.name_length;
}

return 255;
}
}

public int64 compat_fields_limits_value_length {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.value_length;
}

return 255;
}
}

public int64 compat_status_max_media_attachments {
get {
public bool supports_quote_posting {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.features != null) {
return "quote_posting" in pleroma.metadata.features;
}

return false;
}
}

public string[]? compat_supported_mime_types {
get {
if (pleroma != null && pleroma.metadata != null) {
return pleroma.metadata.post_formats;
}

return configuration?.statuses?.supported_mime_types;
}
}

public int64 compat_fields_limits_max_fields {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.max_fields;
}

return 4;
}
}

public int64 compat_fields_limits_name_length {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.name_length;
}

return 255;
}
}

public int64 compat_fields_limits_value_length {
get {
if (pleroma != null && pleroma.metadata != null && pleroma.metadata.fields_limits != null) {
return pleroma.metadata.fields_limits.value_length;
}

return 255;
}
}

public int64 compat_status_max_media_attachments {
get {
if (configuration != null) {
return configuration.statuses.max_media_attachments;
}

return 4;
}
}

public int compat_status_characters_reserved_per_url {
get {
if (configuration != null) {
return configuration.statuses.max_media_attachments;
}
return configuration.statuses.characters_reserved_per_url;
}

return 4;
return 0;
}
}
}

public int64 compat_status_max_characters {
get {
public int64 compat_status_max_characters {
get {
if (configuration != null) {
return configuration.statuses.max_characters;
}
return configuration.statuses.max_characters;
}

return max_toot_chars;
return max_toot_chars;
}
}
}

public int64 compat_status_max_image_size {
get {
public int64 compat_status_max_image_size {
get {
if (configuration != null) {
return configuration.media_attachments.image_size_limit;
}
return configuration.media_attachments.image_size_limit;
}

return upload_limit;
return upload_limit;
}
}
}

public int64 compat_status_max_video_size {
get {
if (configuration != null) {
return configuration.media_attachments.video_size_limit;
}
public int64 compat_status_max_video_size {
get {
if (configuration != null) {
return configuration.media_attachments.video_size_limit;
}

return upload_limit;
return upload_limit;
}
}
}

public API.Mastodon.Configuration.Polls? compat_status_polls {
get {
public API.Mastodon.Configuration.Polls? compat_status_polls {
get {
if (configuration != null) {
return configuration.polls;
}

return poll_limits;
}
}

public int64 compat_status_poll_max_characters {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.compat_status_poll_max_characters;
}

return 50;
}
}

public int64 compat_status_poll_max_options {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.max_options;
}

return 4;
}
}

public int64 compat_status_poll_min_expiration {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.min_expiration;
}

return 300;
}
}

public int64 compat_status_poll_max_expiration {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.max_expiration;
}

return 2629746;
}
}

public static API.Instance from (Json.Node node) throws Error {
return Entity.from_json (typeof (API.Instance), node) as API.Instance;
return configuration.polls;
}

return poll_limits;
}
}

public int64 compat_status_poll_max_characters {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.compat_status_poll_max_characters;
}

return 50;
}
}

public int64 compat_status_poll_max_options {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.max_options;
}

return 4;
}
}

public int64 compat_status_poll_min_expiration {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.min_expiration;
}

return 300;
}
}

public int64 compat_status_poll_max_expiration {
get {
var compat_polls = compat_status_polls;
if (compat_polls != null) {
return compat_polls.max_expiration;
}

return 2629746;
}
}

public static API.Instance from (Json.Node node) throws Error {
return Entity.from_json (typeof (API.Instance), node) as API.Instance;
}
}
2 changes: 1 addition & 1 deletion src/API/Instance/Mastodon/Configuration/Statuses.vala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
public class Tuba.API.Mastodon.Configuration.Statuses : Entity {
public int64 max_characters { get; set; }
public int64 max_media_attachments { get; set; }
public int64 characters_reserved_per_url { get; set; default = 0; }
public int characters_reserved_per_url { get; set; default = 0; }
public string[]? supported_mime_types { get; set; default = null; }
}
Loading

0 comments on commit 26be6de

Please sign in to comment.