GNU social V3https://gnusocial.rocks/v3/index.html Development blog where we announce our progress.en Thu, 09 Dec 2021 14:59:13 +0000 Thu, 09 Dec 2021 14:59:13 +0000 Milestone: Actor colour theme plugin Actors are now able to set their own colours, through a brand new plugin: "Oomox". Those accustomed to customising their own desktop should know where the name comes from ;)

Here's how it works!

The Oomox plugin main class catches the "PopulateProfileSettingsTabs" event upon visiting user panel.

public function onPopulateProfileSettingsTabs(Request $request, array &$tabs): bool
{
    $tabs[] = [
        'title'      => 'Light theme colours',
        'desc'       => 'Change the theme colours.',
        'controller' => C\Oomox::oomoxSettingsLight($request),
    ];

    $tabs[] = [
        'title'      => 'Dark theme colours',
        'desc'       => 'Change the theme colours.',
        'controller' => C\Oomox::oomoxSettingsDark($request),
    ];

    return Event::next;
}

As made evident by the code, two new tabs are added to profile settings, light and dark theme colours. Since the page styling follows the system theme, actors may want to style each theme differently, therefore they are treated separately.

The actor's defined colours are then saved in the respective entity and cached. Finally, the colour preferences are used to render the corresponding CSS file which defines the various colour variables used:

public function oomoxCSS(): Response
{
    $user = Common::ensureLoggedIn();

    $oomox_table = PluginOomox::getEntity($user);
    if (is_null($oomox_table)) {
        throw new ClientException(_m('No custom colours defined', 404));
    }

    $content = Formatting::twigRenderFile('/oomox/root_override.css.twig', ['oomox' => $oomox_table]);
    return new Response($content, status: 200, headers: ['content-type' => 'text/css']);
}

Please note, upon rendering for the first time, page render may be blocked until the resulting file is served. Nonetheless, subsequent page renders won't experience the issue again. That is, if the file is cached by the browser.

How it looks

Tabs added using the "PopulateProfileSettingsTabs" event: User panel Oomox sections

Changing the dark theme colours! Dark theme colours selection

The result of given changes, please note it's no longer a 'dark' theme. Given a valid colour, it's the actor's responsibility whether or not the colours make sense. So, go wild! The resulting colours in action!

]]>
https://gnusocial.rocks/v3/milestone-actor-colour-theme-plugin.html https://gnusocial.rocks/v3/./milestone-actor-colour-theme-plugin.html GNU social development team Thu, 09 Dec 2021 14:58:35 +0000
Milestone: ActivityPub ActivityPub Plugin source.

This milestone could be just this, what's different from any other ActivityPub plugin? How is it better than v2's?

It's better in how it's organised and extensible. See the examples below to have an idea.

To extend an Activity properties you do:

public function onActivityPubValidateActivityStreamsTwoData(string $type_name, array &$validators): bool {
    if ($type_name === '{Type}') {
        $validators['attribute'] = myValidator::class;
    }
    return Event::next;
}

The Validator should be of the form:

class myValidator extends Plugin\ActivityPub\Util\ModelValidator
{
    /**
     * Validate Attribute's value
     *
     * @param mixed $value from JSON's attribute
     * @param mixed $container A {Type}
     * @return bool
     * @throws Exception
     */
    public function validate($value, $container): bool
    {
        // Validate that container is a {Type}
        Util::subclassOf($container, Type\Extended\Object\{Type}::class, true);

        return {Validation Result};

To act on received activities do:

public function onActivityPubNew{Type}(&$obj): bool {

To add information to Activities being federated by ActivityPub do:

public function ActivityPubAddActivityStreamsTwoData(string $type_name, &$type): bool {

To implement an ActivityStreams 2.0 representation do:

public function onActivityPubActivityStreamsTwoResponse(string $route, arrray $vars, ?TypeResponse &$response = null): bool {
        if ($route === '{Object route}') {
                $response = ModelResponse::handle($vars[{Object}]);
                return Event::stop;
        }
        return Event::next;
}
]]>
https://gnusocial.rocks/v3/milestone-activitypub.html https://gnusocial.rocks/v3/./milestone-activitypub.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Milestone: ActivityStreams 2.0 and WebFinger The primary use of GNU social is to access the free network, be it ActivityWeb (ActivityPub) or Fediverse (OStatus).

Contrary to the original plan, we have merged The Free Network Module, WebFinger and LRDD into a single component named FreeNetwork. Likewise, ActivityPub and ActivityStreams 2.0 was kept the same plugin instead of separated.

Understanding the organisation chosen

The FreeNetwork component adds WebFinger (RFC7033) lookup and implements Link-based Resource Descriptor Discovery (LRDD) based on RFC6415, Web Host Metadata. It takes and produces both Extensible Resource Descriptor (XRD) and JSON (JavaSript Object Notation). Furthermore, and different from v2, every federation protocol will use the same distribution queue maintained by this component instead of holding its own.

We originally intended to have data modelling plugins that would extend the GS's "language". We then understood that it added more complexity than we wanted without any considerable advantage because we cannot dissociate data reception handling of the protocol itself.

Situation Report

ActivityPub already translates between activity and entity and allows plugins to extend it (thus serving a similar purpose to data modelling and representation plugins).

GNU social v3 now supports mentions, which is a process that starts in the Posting component. The processing of local mentions naturally finds its entire handling here.

For remote ActivityPub mentions, ActivityPub handles it aided by the FreeNetwork component).

Next steps

We still have to port OStatus (and ActivityStreams 1.0) and implement the distribution by FreeNetwork, although the base work is done. Regarding ActivityPub, although some of it already works, expanding the existing plugins to supplement ActivityPub, and full validation isn't ready yet. We will most likely finish the implementation of the whole federation stack in the next week.

]]>
https://gnusocial.rocks/v3/milestone-activitystreams-20-and-webfinger.html https://gnusocial.rocks/v3/./milestone-activitystreams-20-and-webfinger.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Milestone: Documentation and Tests Infrastructure >WIKI Milestone entry

GNU social now has its documentation available in https://docs.gnusocial.rocks/. It features four different books. These are automatically generated from the source using mdBook.

Only the development book is in an elaborated state, the other books are holding for more ready code.

And two of them are new:

  • The Developer is both intended to guide third-party plugin developers and to make it easier of contributing to the code.
  • The Designer is the most recent of the four and came from a necessity of keeping some standardization between templates and ensuring the same principles are kept in mind when designing new themes.

And two of them are updates from existing documentation:

Together with the documentation we've introduced a wiki. Its purpose is to walk-through decisions, convention, terminology. It's where we document the reasoning the development team went through before implementing more sophisticated functionalities.

Finally, when the documentation doesn't explain, and to ensure the whole code is properly tested, we have the tests. And the coverage is available here. At the time of writing the coverage has 98.76% code lines tested.

]]>
https://gnusocial.rocks/v3/milestone-documentation-and-tests-infrastructure.html https://gnusocial.rocks/v3/./milestone-documentation-and-tests-infrastructure.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Milestone: Notes and Actors with languages Well, it's that, our notes now have a language attribute.

... All right, all right, it's not just it.

Here's what comes with it:

Here's how it looks

First, the user panel section where the desired preferences are selected: User panel language settings section

Upon sending the previous form, the user is redirected to order their selection: Ordering the selections made in previous page

Finally, when posting the language with the highest priority is selected by default.

However, by accessing "Additional options", another language may be selected. The resulting note will have the lang attribute according to it.

The posting widget itself: Selecting the language of a note when posting

What does this mean?

We can now show you the notes you can read, but for groups, this mean that you can access umbrella groups and filter the feeds to see what's in your language and even region.

For too long the fediverse struggled with languages, this step makes it easier for actual internationalization of the free network.

]]>
https://gnusocial.rocks/v3/milestone-notes-and-actors-with-languages.html https://gnusocial.rocks/v3/./milestone-notes-and-actors-with-languages.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Milestone: Port Media handling from v2 >WIKI Milestone entry

File Storage in GNU social is used for avatars, for notes containing attachments, and for notes containing links (in which case is an Embed preview). Notes can be created by local users or fetched from remote actors. Filehash is used to reduce file duplication.

When a user shares a Link that uses OpenGraph tags or has an OEmbed provider, the Embed plugin generates a preview for it that may contain a thumbnail.

When a user shares a Link to an image, the StoreRemoteMedia plugin can fetch the file and make it available as an attachment, and will generate a thumbnail.

When an image, video, or other file type is uploaded or retrieved, an Attachment entity is created. When a thumbnail is requested, one is generated if an EncoderPlugin that supports the mime type is available.

There are two EncoderPlugins implemented:

  • ImageEncoder: Allows to compress, validate, rescale, and sanitize images using VIPS.
  • VideoEncoder: Allows to rescale gifs using FFMpeg.

Another helpful plugin is FileQuota which ensures a user stays under the file quota.

How is the code organised?

There are various entities related to attachment and thumbnail handling. The key ones are:

The plugins are able to act by means of the Events system, as elaborated in the documentation.

]]>
https://gnusocial.rocks/v3/milestone-port-media-handling-from-v2.html https://gnusocial.rocks/v3/./milestone-port-media-handling-from-v2.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Milestone: Tags

Due to the high density of technical aspects, we decided to keep this blog post more on the light side and focus on explaining the new functionalities. Check our Wiki Milestone entry for all the juicy details.

>WIKI Milestone entry

GNU social v2 has tags and lists. It allows you to: - search for an #hashtag and see a stream of notes tagged with it; - make lists of actors and mention them with @#list_name - self tag and enter a list of people in your instance with the same self tag

It is limited with regards to federation of self tags and the @#list_name can't target remote actors even when they are inside your list.

What's new with v3?

Federated self tags

We now federate self tags and lists, so that constraint from v2 was moved out of the way.

In the future, the use of these tags can allow you to find people, groups and even individual notes that have a tag you're interested in. We only mean filtering, not magic recommendation algorithms.

Tag Wrangling

Proposed by @licho in Tue, 02 Jun 2019 17:52:07 GMT:

I like the tag wrangling feature of AO3, which I think would help for cases of synonymous tags like #introduction and #introductions

https://archiveofourown.org/wrangling_guidelines/11

Is it feasible for !gnusocial ? Or would it cause problems?

The answer is yes and will be released with v3. With the addition of Languages in notes and actors) there was little excuse not to be feasible.

Whenever you post a note containing tags, you can choose whether to make those tags canonical. This means that, for instance, the tags #run and #running become the 'same', meaning that when you click on the link for the #run tag, you'll also see notes tagged #running. You can opt out of the behaviour by unchecking the "Make note tags canonical". An identical process occurs for people tags.

Internally, this transformation is accomplished by splitting the tag into words and stemming each word.

Related Tags

In a tag feed, you can see tags that are often used together with the one you're seeing. This can be useful, for instance, for finding other content you'd be interested in.

Improved Tag feeds

When you click on a tag, be it a note tag or a person tag, you'll see a feed of notes/people with that tag. You can also edit the feeds you see in your left panel, so you can follow a given tag.

Mute Self Tags and Note Tags

If you don't like seeing a given tag in your feeds, for whatever reason, you can choose to mute it. You can mute a note tag or a person tag, in which case you wouldn't see any notes from people with that tag.

]]>
https://gnusocial.rocks/v3/milestone-tags.html https://gnusocial.rocks/v3/./milestone-tags.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Updates: Finish the Avatar component Avatar Component source.

Its controller handles upload, update and removal.

Important change from v2: Avatars are now regular attachments.

]]>
https://gnusocial.rocks/v3/updates-finish-the-avatar-component.html https://gnusocial.rocks/v3/./updates-finish-the-avatar-component.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Updates: Implement StoreRemoteMedia for v3 and port Embed GNU social comes with two plugins that add relevant media functionality. Not talking neither about ImageEncoder nor VideoEncoder this time, but rather about StoreRemoteMedia and Embed.

StoreRemoteMedia fetches remote files when they are Linked to in a note. I.e., when the major mime type isn't text. It triggers thumbnail generation.

Embed attempts to generate a page preview from open graph and oembed. I.e., acts when the major mime type is text.

We've changed so much with GNU social v3 that, regarding SRM there was no possible port, just a complete rewrite. Both plugins became smaller and easier to understand while promoting the same functionality with more stability.

]]>
https://gnusocial.rocks/v3/updates-implement-storeremotemedia-for-v3-and-port-embed.html https://gnusocial.rocks/v3/./updates-implement-storeremotemedia-for-v3-and-port-embed.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000
Updates: Improve the Attachments system With the milestone Port Media system from v2 we had ported the existing attachment system. The fact is that this system wasn't good enough.

It's always important to start with the original code as that allows us to review past decisions and understand all the corner cases previously considered.

Sadly, what motivated us to re-design the attachment system were the non-considered corner cases. In particular:

  • Remove title from attachment, as it's part of the relation between attachment and note.
  • Remove actor from attachment, many actors may publish the same attachment.
  • Remove is_local from attachment, as it's part of the relation between attachment and note.
  • Remove remote_url from attachment, different urls can return the same attachment.
  • Attachment now has a reference counter
  • Add entity GSActorToAttachment
  • Add entity GSActorToRemoteURL
  • Add entity RemoteURL
  • Add entity RemoteURLToNote
  • Add entity RemoteURLToAttachment
  • AttachmentToNote now has a title attribute

Key commits:

The structural changes and how it compares to v2 is detailed in our wiki.

Some relevant observations:

  • Link is now part of GNU social Data Representation terms. It represents any remote URL being shared in a note.
  • There's only one fixed directory for GSFiles.
]]>
https://gnusocial.rocks/v3/updates-improve-the-attachments-system.html https://gnusocial.rocks/v3/./updates-improve-the-attachments-system.html GNU social development team Thu, 09 Dec 2021 14:58:31 +0000