update ggemtext api version

This commit is contained in:
yggverse 2024-12-03 19:29:14 +02:00
parent eb70c2d873
commit a5c0a4bdd0
3 changed files with 12 additions and 15 deletions

View File

@ -866,12 +866,12 @@ pub fn migrate(tx: &Transaction) -> Result<(), String> {
/// Useful as common placeholder when page title could not be detected /// Useful as common placeholder when page title could not be detected
/// ///
/// * this feature may be improved and moved outside @TODO /// * this feature may be improved and moved outside @TODO
fn uri_to_title(uri: &Uri) -> GString { fn uri_to_title(uri: &Uri) -> String {
let title = GString::from(uri.path().split('/').last().unwrap_or_default()); let title = uri.path().split('/').last().unwrap_or_default().to_string();
if title.is_empty() { if title.is_empty() {
match uri.host() { match uri.host() {
Some(host) => gformat!("{host}"), Some(host) => host.to_string(),
None => gformat!("Untitled"), None => "Untitled".to_string(),
} }
} else { } else {
title title

View File

@ -3,14 +3,11 @@ mod gemini;
use gemini::Gemini; use gemini::Gemini;
use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction}; use crate::app::browser::window::{tab::item::Action as TabAction, Action as WindowAction};
use gtk::{ use gtk::{glib::Uri, ScrolledWindow};
glib::{GString, Uri},
ScrolledWindow,
};
use std::rc::Rc; use std::rc::Rc;
pub struct Meta { pub struct Meta {
pub title: Option<GString>, pub title: Option<String>,
} // @TODO move to separated mod } // @TODO move to separated mod
pub struct Text { pub struct Text {

View File

@ -13,7 +13,7 @@ use crate::app::browser::window::{
}; };
use adw::StyleManager; use adw::StyleManager;
use gemtext::line::{ use gemtext::line::{
code::Code, code::{Inline, Multiline},
header::{Header, Level}, header::{Header, Level},
link::Link, link::Link,
list::List, list::List,
@ -22,7 +22,7 @@ use gemtext::line::{
use gtk::{ use gtk::{
gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY}, gdk::{BUTTON_MIDDLE, BUTTON_PRIMARY},
gio::Cancellable, gio::Cancellable,
glib::{GString, TimeZone, Uri}, glib::{TimeZone, Uri},
prelude::{TextBufferExt, TextBufferExtManual, TextViewExt, WidgetExt}, prelude::{TextBufferExt, TextBufferExtManual, TextViewExt, WidgetExt},
EventControllerMotion, GestureClick, TextBuffer, TextTag, TextWindowType, UriLauncher, Window, EventControllerMotion, GestureClick, TextBuffer, TextTag, TextWindowType, UriLauncher, Window,
WrapMode, WrapMode,
@ -35,7 +35,7 @@ pub const LIST_ITEM: &str = "•";
pub const NEW_LINE: &str = "\n"; pub const NEW_LINE: &str = "\n";
pub struct Reader { pub struct Reader {
pub title: Option<GString>, pub title: Option<String>,
pub widget: Rc<Widget>, pub widget: Rc<Widget>,
} }
@ -67,7 +67,7 @@ impl Reader {
// Parse gemtext lines // Parse gemtext lines
for line in gemtext.lines() { for line in gemtext.lines() {
// Is inline code // Is inline code
if let Some(code) = Code::inline_from(line) { if let Some(code) = Inline::from(line) {
// Append value to buffer // Append value to buffer
match syntax.highlight(&code.value, &tag.code.text_tag, None) { match syntax.highlight(&code.value, &tag.code.text_tag, None) {
Ok(highlight) => { Ok(highlight) => {
@ -104,7 +104,7 @@ impl Reader {
match multiline { match multiline {
None => { None => {
// Open tag found // Open tag found
if let Some(code) = Code::multiline_begin_from(line) { if let Some(code) = Multiline::begin_from(line) {
// Begin next lines collection into the code buffer // Begin next lines collection into the code buffer
multiline = Some(code); multiline = Some(code);
@ -113,7 +113,7 @@ impl Reader {
} }
} }
Some(ref mut this) => { Some(ref mut this) => {
match Code::multiline_continue_from(this, line) { match Multiline::continue_from(this, line) {
Ok(()) => { Ok(()) => {
// Close tag found: // Close tag found:
if this.completed { if this.completed {