Japanese Speaker. I can read/write some English but not well, so corrections are always appreciated.

プログラミングや音楽に興味があります。いまはkbinのソースやActivityPubの仕様を読んだりしています。

  • 2 Posts
  • 16 Comments
Joined 1 year ago
cake
Cake day: June 18th, 2023

help-circle
  • Some applications can’t display some Unicode strings like s̵t̵r̵o̵k̵e̵, so replacing Markdown element like ~strike~ with Unicode equivalent (s̵t̵r̵o̵k̵e̵ ) may not be a good idea if you want portability. I opened your post in text editors and noticed that neovim-qt drops s̵t̵r̵o̵k̵e̵’s combining characters (issue on Github) and just displays stroke instead of s̵t̵r̵o̵k̵e̵; GUI Emacs with my font settings (Noto) doesn’t combine the characters and displays s-t-r-o-k-e- (as I said, this may depends on font settings).


















  • Hi, thanks for setting up this community. I’m not a Lemmy source contributer but I like to read open sources. Here is a very simplified web application (including Lemmy) architecture overview and I hope this text helps for some newbies:

    1. A user agent (web browser, mobile app, etc.) sends an HTTP request to a Lemmy instance.
    2. The lemmy instance examines the HTTP request and dispatches the request to a relevant function called controller. The mapping from a path in the URL to a function is called a router - see https://github.com/LemmyNet/lemmy/blob/0.19.3/src/api_routes_http.rs for example.
    3. The controller makes an HTTP response for the request and returns it to the user agent.
    4. The user agent displays the returned response to the user.

    To find an controller from a path in the router, just grep (or a similar search function you use) the Lemmy source. For example, if I want to know how GET /user/export_settings works, I’ll run these commands:

    $ git clone https://github.com/LemmyNet/lemmy/  # if you haven't download the source yet
    $ cd lemmy
    $ rg export_settings
    src/api_routes_http.rs
    131:  user_settings_backup::{export_settings, import_settings},
    274:        web::resource("/user/export_settings")
    276:          .route(web::get().to(export_settings)),
    
    crates/apub/src/api/user_settings_backup.rs
    68:pub async fn export_settings(
    301:  use crate::api::user_settings_backup::{export_settings, import_settings};
    366:    let backup = export_settings(export_user.clone(), context.reset_request_count()).await?;
    402:    let mut backup = export_settings(export_user.clone(), context.reset_request_count()).await?;
    

    So we got the relevant route and the controller definitions very quickly. Settings to be exported are defined as a struct UserSettingsBackup. The controller is defined as pub async fn export_settings and it converts the struct to a JSON.

    Rust might not be a easy programming language but the official text (calld The Book is very friendly for newbies, so don’t hesitate to read and to write a simple program like guessing game.