<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Christoph Wurst</title>
    <description>My personal blog.</description>
    <link>https://blog.wuc.me/</link>
    <atom:link href="https://blog.wuc.me/feed.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Thu, 27 Nov 2025 06:43:44 +0000</pubDate>
    <lastBuildDate>Thu, 27 Nov 2025 06:43:44 +0000</lastBuildDate>
    <generator>Jekyll v3.10.0</generator>
    
      <item>
        <title>Uploading Wahoo workouts to intervals.icu</title>
        <description>&lt;p&gt;The Wahoo Elemnt companion app pulls workout files off my bike computer in the &lt;a href=&quot;https://developer.garmin.com/fit/protocol/&quot;&gt;.fit file format&lt;/a&gt;. The workout can then be viewed, uploaded to a number of serivces and shared with other apps.&lt;/p&gt;

&lt;p&gt;Unfortunately, &lt;a href=&quot;https://intervals.icu/&quot;&gt;intervals.icu&lt;/a&gt; is not on the list of integrations. This makes it impossible to directly, or even automatically, upload workouts there. Bummer.&lt;/p&gt;

&lt;h2 id=&quot;the-fully-manual-route&quot;&gt;The fully manual route&lt;/h2&gt;

&lt;p&gt;If I want to I can attach the bike computer to my notebook via USB and upload the file to intervals from there. This is possible, but tedious.&lt;/p&gt;

&lt;h2 id=&quot;taking-a-detour&quot;&gt;Taking a detour&lt;/h2&gt;

&lt;p&gt;It wasn’t quite obvious to me at the beginning but it’s possible to use the workout &lt;em&gt;sharing&lt;/em&gt; feature to send the .fit file to another app. Sharing it to the Nextcloud Android app allows me to pick a destination folder and upload the workout file right into my cloud files.&lt;/p&gt;

&lt;p&gt;If I then have the folder sync’ed to my notebook I can upload it to intervals more conveniently, without any cable. Still, this is a repetitive and scriptable task.&lt;/p&gt;

&lt;h2 id=&quot;the-shortcut&quot;&gt;The shortcut&lt;/h2&gt;

&lt;p&gt;Fortunately &lt;a href=&quot;https://intervals.icu/&quot;&gt;intervals.icu&lt;/a&gt; offers &lt;a href=&quot;https://forum.intervals.icu/t/api-access-to-intervals-icu/609&quot;&gt;a public API&lt;/a&gt; and a resource to push workouts to.&lt;/p&gt;

&lt;p&gt;This API lends itself perfectly for an automation based on &lt;a href=&quot;https://nextcloud.com/workflow/&quot;&gt;Nextcloud Workflows&lt;/a&gt;. All it takes is registering a new operation and listen for the &lt;em&gt;file post create&lt;/em&gt; event.&lt;/p&gt;

&lt;p&gt;As a user I can then set up a new workflow rule that takes .fit files and passes it to the intervals.icu operation that takes care of the upload.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20220627_wahoo_intervals_icu_nextcloud/user_setting.png&quot; alt=&quot;Setting up Nextcloud Workflows&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The only thing left is to configure the operation with my intervals athlete ID and API key. I can add it to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;oc_preferences&lt;/code&gt; table manually.&lt;/p&gt;

&lt;p&gt;With this tiny workflow app my workouts can be sent to Nextcloud from my phone and show on intervals in a matter of seconds.&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;I was able to automate a small but repetitive task in a matter of a few hours. The app was actually written seven months ago and I only had to update it to bump the info.xml for new Nextcloud releases.&lt;/p&gt;

&lt;p&gt;By intervals.icu’s popularity I expect it to be supported directly by Wahoo at some point. Until then I have my custom solution. As a side effect I’m also backing up my workouts to Nextcloud.&lt;/p&gt;

&lt;p&gt;The app is open source and &lt;a href=&quot;https://github.com/ChristophWurst/workflow_intervalsicu&quot;&gt;can be found on Github&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Mon, 27 Jun 2022 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2022/06/27/wahoo-intervals-icu-nextcloud.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2022/06/27/wahoo-intervals-icu-nextcloud.html</guid>
        
        <category>foss</category>
        
        <category>sports</category>
        
        <category>intervals.icu</category>
        
        <category>nextcloud</category>
        
        
      </item>
    
      <item>
        <title>Mail v1.7.0, 1.6.1 &amp; v1.5.3</title>
        <description>&lt;p&gt;It’s been just a week since I announced Mail v1.6.1 here on this blog and yet there is a new release – v1.7.0.&lt;/p&gt;

&lt;p&gt;In this minor update we have three new features:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You can now move mailboxes around. Like from the root to a submailbox, from one mailbox to another or from a submailbox to the root.&lt;/li&gt;
  &lt;li&gt;Improved HTML rendering makes the iframe that contains the email HTML responsive in height, so it will expand to the full content. Moreover, we previously trimmed some specialized formatting and some emails looked a bit different when compared to other email clients. Most of these differences are fixed now.&lt;/li&gt;
  &lt;li&gt;Existing messages can be edited as new one. Like if you just sent a message to Alice you can send the same message to Bob.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/nextcloud/mail/releases/tag/v1.7.0&quot;&gt;Here’s the full changelog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cheers :v:&lt;/p&gt;
</description>
        <pubDate>Wed, 11 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2020/11/11/nextcloud-mail-1-7.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2020/11/11/nextcloud-mail-1-7.html</guid>
        
        <category>nextcloud</category>
        
        <category>email</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>Mail v1.6.0 &amp; v1.5.2</title>
        <description>&lt;p&gt;I’m happy to announce that we’ve released a new version of &lt;a href=&quot;https://apps.nextcloud.com/apps/mail&quot;&gt;Nextcloud Mail&lt;/a&gt; today. The most notable changes are the ability to &lt;em&gt;move messages&lt;/em&gt; via a brand new mailbox picker, a new &lt;em&gt;preferences setting&lt;/em&gt; that allows you to pick custom mailboxes for draft, sent and deleted emails, improvements to how emails are displayed in the thread view as well as some enhancements to the multiselect for power users.&lt;/p&gt;

&lt;p&gt;As always there are also a ton of fixes and improvements that are not notable to the users. You can find the full changelog &lt;a href=&quot;https://github.com/nextcloud/mail/releases/tag/v1.6.0&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;As php7.2 is reaching EOL we decided to drop the support and Mail v1.6 and later will require php7.3. We’ve also published an updated version of v1.5 as v1.5.2 that received the most critical bugfixes for those that are still on php7.2 or simply don’t want to update to v1.6 yet.&lt;/p&gt;

&lt;p&gt;If you need any help using the app or you have some question please let us know &lt;a href=&quot;https://help.nextcloud.com/c/features-apps/mail/35&quot;&gt;on the forum&lt;/a&gt; :v:&lt;/p&gt;
</description>
        <pubDate>Wed, 04 Nov 2020 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2020/11/04/nextcloud-mail-1-6.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2020/11/04/nextcloud-mail-1-6.html</guid>
        
        <category>nextcloud</category>
        
        <category>email</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>Mailvelope in Nextcloud Mail, refined</title>
        <description>&lt;p&gt;Nextcloud Mail has offered PGP encryption via a third-party browser extension &lt;a href=&quot;https://mailvelope.com/en&quot;&gt;Mailvelope&lt;/a&gt; for a while. Recently we discovered that there were some issues due to our rich text editor. This led me into revisiting the integration and my attempted &lt;em&gt;bugfix&lt;/em&gt; turned into quite an &lt;em&gt;enhancement&lt;/em&gt;.&lt;/p&gt;

&lt;h2 id=&quot;what-we-had-before&quot;&gt;What we had before&lt;/h2&gt;

&lt;p&gt;Prior to Mail v1.3.5, our app was not even aware of the Mailvelope integration. The user configured their Nextcloud domain in the extension settings and Mailvelope would dected textareas and similar HTML inputs and show a button to open a popup with the encryption editor. The user then had to pick the recipients again (Mailvelope had no clue about the recipient selection in Nextcloud Mail) and once the message got encrypted, it was written back to the original window.&lt;/p&gt;

&lt;p&gt;This solution worked okay-ish for a long time, but  never felt seamless due to the redundant recipient selection and the popup window.&lt;/p&gt;

&lt;h2 id=&quot;switching-to-api-mode&quot;&gt;Switching to API mode&lt;/h2&gt;

&lt;p&gt;To get some help with fixing the integration after breaking with our CKEditor as rich text editor, I contacted Mailvelope support and got quick feedback from one of the developers. I was introduced into the API mode, where an application integrating Mailvelope could interact with the extension programmatically.&lt;/p&gt;

&lt;p&gt;This means Nextcloud Mail is now capable of knowing whether Mailvelope is installed and enabled for the domain.&lt;/p&gt;

&lt;h2 id=&quot;the-new-sending-experience&quot;&gt;The new sending experience&lt;/h2&gt;

&lt;p&gt;As Mail is now capable of detecting Mailvelope, it will show an encryption option in the new message composer.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20200518_nextcloud_mail_mailvelope_refined/actions.png&quot; alt=&quot;The &amp;quot;Ecrypt message with Mailvelope&amp;quot; option in Nextcloud Mail v1.3.5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Note that the &lt;em&gt;Send&lt;/em&gt; button also now indicated whether whether the composed message will be sent encrypted or in plain text. Simple installations without Mailvelope will still only show &lt;em&gt;Send&lt;/em&gt;, so the interface is less complex for those users.&lt;/p&gt;

&lt;p&gt;Once the encryption option is enabled, the editor component will be replaced by an editor of Mailvelope.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20200518_nextcloud_mail_mailvelope_refined/encrypted_email.png&quot; alt=&quot;The Mailvelope editor in Nextcloud Mail v1.3.5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;See, no more popup window! No more redundant recipient selection. Nextcloud Mail will pass the recipients to Mailvelope for you. In fact, it will even check if all the picked recipients have a key available and prevent sending if this condition is not met.&lt;/p&gt;

&lt;h2 id=&quot;better-reading-experience&quot;&gt;Better reading experience&lt;/h2&gt;

&lt;p&gt;The switch to the &lt;em&gt;API version of Mailvelope&lt;/em&gt; also allows us to embed a display container into Nextcloud Mail, so the experience feels a bit more integrated.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20200518_nextcloud_mail_mailvelope_refined/display.png&quot; alt=&quot;The Mailvelope editor in Nextcloud Mail v1.3.5&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can directly see and download the attachments.&lt;/p&gt;

&lt;h2 id=&quot;smoother-replies&quot;&gt;Smoother replies&lt;/h2&gt;

&lt;p&gt;When replying to an encrypted message, we will pass the raw data into Mailvelope. The extension will decrypt and quote the message for you, so it’s very convenient to have encrypted conversations.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20200518_nextcloud_mail_mailvelope_refined/reply.png&quot; alt=&quot;The Mailvelope editor in Nextcloud Mail v1.3.5&quot; /&gt;&lt;/p&gt;

&lt;h2 id=&quot;get-it-now&quot;&gt;Get it now&lt;/h2&gt;

&lt;p&gt;Nextcloud &lt;img src=&quot;https://apps.nextcloud.com/apps/mail&quot; alt=&quot;Mail v1.3.5 has just been relased to the app store&quot; /&gt;. Upgrade and start encrypting more messages now :wink:&lt;/p&gt;

&lt;p&gt;If you have any questions or feedback please let us know &lt;a href=&quot;https://help.nextcloud.com/t/mailvelope-in-nextcloud-mail-refined/81967&quot;&gt;on the forum&lt;/a&gt; :)&lt;/p&gt;
</description>
        <pubDate>Mon, 18 May 2020 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2020/05/18/nextcloud-mail-mailvelope-refined.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2020/05/18/nextcloud-mail-mailvelope-refined.html</guid>
        
        <category>nextcloud</category>
        
        <category>mail</category>
        
        <category>announcement</category>
        
        
      </item>
    
      <item>
        <title>Rock Me Amadeus: Escaping the php Dependency Hell</title>
        <description>&lt;p&gt;Similar to some other programming language and environments, php is subject a form of the &lt;a href=&quot;https://en.wikipedia.org/wiki/Dependency_hell&quot;&gt;dependency hell&lt;/a&gt;. That means only one version of a class can be loaded at a time. For simple applications that is less of a problem as you will most likely composer to manage your dependencies. Composer flattens your dependency hierarchy so all required packages and their sub-packages can live next to each other while all version constraints are satisfied. If one library is required with two or more disjoint version ranges, composer will show an error and refuse the installation.&lt;/p&gt;

&lt;h2 id=&quot;nextcloud-and-the-dependency-hell&quot;&gt;Nextcloud and the Dependency Hell&lt;/h2&gt;

&lt;p&gt;With Nextcloud apps it’s even a bit more complicated. We use composer for our libraries, but the pluggable architecture allows apps to ship additional code. This code is not only the application code, but also often additional packages via the app’s composer. As the Nextcloud composer and any app’s composer are not aware of each other, both will register a class autoloader therefore there is the chance that two or more app load a dependency multiple times. In the lucky case, nobody notices as both apps use the same (latest) version of the dependency. In the less lucky case, there will be strange bugs as parts of the one version of the package and parts of the other are loaded. When admins who detect the problem report it, it can typically not be reproduced because the developer’s instance might not have both conflicting applications installed.&lt;/p&gt;

&lt;h2 id=&quot;a-promising-workaround&quot;&gt;A Promising Workaround&lt;/h2&gt;

&lt;p&gt;Again, a typical php application won’t ever run into this problem. But it’s not only Nextcloud which is affected by this problem – Wordpress has the exact same issue with its plugins. Mozart is a small package that promises to help. It rewrites source file from composer’s vendor directory and prefixes the namespaces with a configurable prefix. This means every Wordpress plugin or Nextcloud app can have its own set of dependencies, while they will never cause a conflict thanks to the unambiguous namespaces.&lt;/p&gt;

&lt;p&gt;I think this is brilliant, and possibly the only real solution to this problem unless that would be ever addresses on a language level where more than one autoloader could handle the loading of classes inside encapsulated bundles.&lt;/p&gt;

&lt;p&gt;A few experiments with the tool in a Nextcloud app have shown that it does work. The only composer package where it broke is Guzzle with HTTPlug, as some libraries are not correctly re-written and thus the service locator logic fails.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Und alles ruft&lt;/em&gt; &lt;a href=&quot;https://www.youtube.com/watch?v=cVikZ8Oe_XA&quot;&gt;&lt;em&gt;Come and rock me Amadeus&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the discussion around Mozart for Nextcloud apps please see &lt;a href=&quot;https://help.nextcloud.com/t/escaping-the-dependency-hell/81407&quot;&gt;my topic on the community forum&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Wed, 13 May 2020 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2020/05/13/rock-me-amadeus-php-dependency-hell.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2020/05/13/rock-me-amadeus-php-dependency-hell.html</guid>
        
        <category>nextcloud</category>
        
        <category>development</category>
        
        <category>php</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>A Shared Browserslist Configuration for Nextcloud Apps</title>
        <description>&lt;p&gt;In times where most JavaScript is not written for the browser directly but runs through one (or many) tools that transform the syntax and APIs used, it has become a lot easier to be compatible with a wider range of browsers. In order to keep the size of the generated code reasonable, it’s necessary to limit the set of browsers and browser versions supported.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://github.com/browserslist/browserslist&quot;&gt;Browserslist&lt;/a&gt; allows developers to declare these browsers and versions, from which it generates the support matrix. Other tools can use this information when the transpile or generate code. One of them is &lt;a href=&quot;https://babeljs.io/&quot;&gt;Babel&lt;/a&gt;, the JavaScript compiler.&lt;/p&gt;

&lt;p&gt;If you develop an app for Nextcloud, it makes sense to use the same support matrix to ensure that your code is compatible with the same browsers. For this purpose we created and released a shared Browserslist config: &lt;a href=&quot;https://www.npmjs.com/package/@nextcloud/browserslist-config&quot;&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;@nextcloud/browserslist-config&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To use the shared config, install it via &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;npm&lt;/code&gt; and let the share config extend your specific one (if any). Details about installation and usage can be found &lt;a href=&quot;https://www.npmjs.com/package/@nextcloud/browserslist-config#installation&quot;&gt;on the package website&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this is useful for Nextcloud app developers. Any feedback or changes on the support matrix may be submitted &lt;a href=&quot;https://github.com/nextcloud/browserslist-config&quot;&gt;on Github&lt;/a&gt; :v:&lt;/p&gt;
</description>
        <pubDate>Tue, 22 Oct 2019 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2019/10/22/shared-browserslist-config.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2019/10/22/shared-browserslist-config.html</guid>
        
        <category>nextcloud</category>
        
        <category>development</category>
        
        <category>javascript</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>The Problem of Using Nextcloud&apos;s Globally Loaded Dependencies</title>
        <description>&lt;p&gt;Many Nextcloud apps that serve a front-end component have been rewritten in Vue.js recently. With this change to a more modern framework and concept for building user interfaces, more apps have also started using webpack to bundle scripts, styles and even icons. In this post I would like to reflect on why this is important and why more apps should do it.&lt;/p&gt;

&lt;h2 id=&quot;️-writing-nextcloud-app--the-old-approach&quot;&gt;🕵️ Writing Nextcloud app – the old approach&lt;/h2&gt;

&lt;p&gt;Before bundlers like webpack became popular in the Nextcloud community, most apps did not use any bundling for their assets. This means scripts and style sheets were included via HTML’s &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;script&amp;gt;&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;style&amp;gt;&lt;/code&gt; tags.
This style of front-end programming comes with a few problems and limitations.&lt;/p&gt;

&lt;h3 id=&quot;-increased-number-of-requests&quot;&gt;🐌 Increased number of requests&lt;/h3&gt;
&lt;p&gt;With the modular architecture of Nextcloud and having loaded many apps, this design results in numerous requests for a page load without a populated cache. The more files (modules) an app has, the more requests the browser has to wait for before the page can fully work.&lt;/p&gt;

&lt;p&gt;Some developers start with small modules, others split larger onces when they refactor their code that might otherwise become unmaintainable. However, if you are aware of the problem of too many requests on page load, you might rather inline a small module than separating it into a self-contained module. Eventually, this leads to a lower code quality and less maintainable code. &lt;a href=&quot;https://github.com/nextcloud/server/blob/stable16/core/js/js.js&quot;&gt;Here is a prime example.&lt;/a&gt;&lt;/p&gt;

&lt;h3 id=&quot;-loading-order&quot;&gt;🧮 Loading order&lt;/h3&gt;
&lt;p&gt;With splitting code into modules, you will face problems with module dependencies. That means you have to load all your script files in an order in which each module is loaded after the modules it depends on. You can solve this problem with topological sorting, but not all dependency graphs are easy to identify, nor is it always possible to prevent cyclic dependencies. Moreover, these modules are very fragile to refactor, because moving code around can break out due to loosely defined dependence on another module, usually via the assumption of the existence of global variables.&lt;/p&gt;

&lt;h3 id=&quot;-using-custom-libraries-and-frameworks&quot;&gt;💥 Using custom libraries and frameworks&lt;/h3&gt;
&lt;p&gt;A very simple Nextcloud app might only need plain JavaScript. Maybe it needs jQuery. But how can that app use jQuery? Luckily jQuery is already loaded with Nextcloud as the global ˋ$ˋ variable. The app requires library X? Well, it can just load it with another script tag. All fine, right? Not quite, actually.
The problem we’re seeing here is called &lt;em&gt;dependency hell&lt;/em&gt;. In the context of Nextcloud it means that apps have a hard dependency on the libraries shipped with Nextcloud. They work or break depending on if and which version of a library Nextcloud loads. In return, Nextcloud server developers are very limited in changing (updating/removing) those libraries as the product improves and libraries get outdated. A simple upgrade from jQuery 2.x to 3.x will break all apps that are incompatible with that version, making the Nextcloud server unable to migrate away from that outdated version.&lt;/p&gt;

&lt;p&gt;In the same context, apps loading their own libraries will pollute the global namespace as libraries register themselves there 🤦. Should two apps try to load the same library, they will overwrite each other’s instance. Again, this is the &lt;em&gt;dependency hell&lt;/em&gt; problem. With this type of module design, it is impossible to use two version of the same library on the very same page.&lt;/p&gt;

&lt;h3 id=&quot;-browser-compatibility&quot;&gt;💣 Browser compatibility&lt;/h3&gt;
&lt;p&gt;If source files are loaded in the browser directly, they have to be written in a syntax that is compatible with all the browsers that are supported. Sometimes this is easy, sometimes this is hard to test because many developers only develop and test on fast, modern browsers while legacy browsers should be supported as well.&lt;/p&gt;

&lt;h2 id=&quot;-the-solution&quot;&gt;🙌 The Solution&lt;/h2&gt;
&lt;p&gt;In general, the solution to the problems above is to use a bundler tool that combines scripts, styles and other assets into fewer files. In the extreme case, it will combine all front-end assets of an app into a single file.
Right now, one of the widely used tools is &lt;em&gt;webpack&lt;/em&gt;. Webpack can take JavaScript modules in different formats, analyze their dependency tree and combine them to a bundle. In essence, you just have to tell webpack your &lt;em&gt;entry point&lt;/em&gt; and it will figure out the rest, based on the dependcy declarations in the source modules.
Therefore this solves the problem of too many request on page load. With a bundler like webpack, having many small modules does not have any negative impact on your page performance anymore. Developers can properly structure chunks of codes into small, reusable modules and webpack will do its magic and combine them for the browser.&lt;/p&gt;

&lt;p&gt;In terms of dependency hell with more than one version of a library, webpack can load modules installed via packages of &lt;em&gt;npm&lt;/em&gt;, the node package manager. With this apps can install an arbitrary version of their software dependencies and bundle them with webpack, without having any impact on other code. The dependencies won’t be registered in the global namespace anymore. Instead, webpack will inject them wherever they are imported in modules. This not only keeps the global namespace clean, it will also perform better as the JavaScript interpreter can find the references to libraries quicker when they are declared locally.&lt;/p&gt;

&lt;h2 id=&quot;-the-long-term-goal&quot;&gt;🤔 The Long-term Goal&lt;/h2&gt;
&lt;p&gt;In the long run, it would be great if more apps switch to webpack or a similar tool. Because then the server component will be independent of apps again, so that its code and dependencies can be managed, updated and removed independently without breaking any apps that rely on them.&lt;/p&gt;
</description>
        <pubDate>Wed, 12 Jun 2019 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2019/06/12/problem-nextcloud-global-dependencies.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2019/06/12/problem-nextcloud-global-dependencies.html</guid>
        
        <category>nextcloud</category>
        
        <category>development</category>
        
        <category>javascript</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>Detecting Suspicious Nextcloud Logins</title>
        <description>&lt;p&gt;With &lt;a href=&quot;https://nextcloud.com/blog/nextcloud-16-introduces-machine-learning-based-security-and-usability-features-acl-permissions-and-cross-app-projects/&quot;&gt;Nextcloud 16&lt;/a&gt; we release a new security app: &lt;em&gt;&lt;a href=&quot;https://apps.nextcloud.com/apps/suspicious_login&quot;&gt;Suspicious Login&lt;/a&gt;&lt;/em&gt;. This app can detect anomalies in IP addresses logging into a user’s Nextcloud account using supervised learning of an artificial neural network.&lt;/p&gt;

&lt;h2 id=&quot;an-overview&quot;&gt;An Overview&lt;/h2&gt;

&lt;p&gt;Whenever a user logs into Nextcloud, a trained model of a neural network is loaded and used to classify the combination of IP and user ID (UID) as either suspicious or not suspicious. In the former case the user is informed immediately with a (push) notification to their desktop and mobile clients.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20190424_nextcloud_suspiciou_login_detection/notification_android.png&quot; alt=&quot;Nextcloud Android app showing a suspicious login into the user&apos;s account&quot; /&gt;&lt;/p&gt;

&lt;p&gt;An affected user can then change their password or kill any device token that looks unfamiliar to them.&lt;/p&gt;

&lt;h2 id=&quot;your-cloud-your-data&quot;&gt;Your cloud, your data&lt;/h2&gt;

&lt;p&gt;In order to train and use a neural network to classify logins, we need some good training data. While we could ship a pre-trained model that has already learned the structure of IP addresses and a shorter time to practical use, we know that Nextcloud admins and users value privacy. Therefore the app only uses data from the instance.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Suspicious Login&lt;/em&gt; app will collect (IP, UID) tuples from every login and every client connection. After a few weeks of collection, this data can be used for training. The training data is updated continuously as is the trained model.&lt;/p&gt;

&lt;p&gt;As training data is only gather from the instance, the classifier should be less of a black box, but deliver highly customized results while valuing user data privacy.&lt;/p&gt;

&lt;h2 id=&quot;gathering-good-training-data&quot;&gt;Gathering &lt;em&gt;good&lt;/em&gt; training data&lt;/h2&gt;

&lt;p&gt;To get the best classifier possible, it is important to have a good set of training data for the neural network. Successful logins form the positive data set. But we also need negative samples. As we don’t have such data in an ideal scenario we have to fake it.&lt;/p&gt;

&lt;h3 id=&quot;random-samples&quot;&gt;Random samples&lt;/h3&gt;

&lt;p&gt;The simplest way to get random data samples is to use a random number generator to generate IP addresses. Combined with existing users, they simulate logins from IP addresses that are very different to a user’s previous login sources.&lt;/p&gt;

&lt;h3 id=&quot;shuffled-samples&quot;&gt;Shuffled samples&lt;/h3&gt;

&lt;p&gt;The neural net should not only warn about IPs it hasn’t seen before in general, but also when a user tries to log into another user’s account. This is less relevant for environments where many users of the same instance use Nextcloud from the same network, but makes most sense for shared instances, e.g. on hosted providers, or remote companies.&lt;/p&gt;

&lt;p&gt;The app therefore shuffles randomly picked data from the positive training set and mixes UIDs with IPs that a specific user has not logged in from before.&lt;/p&gt;

&lt;h2 id=&quot;separation-of-training-and-validation-data-sets&quot;&gt;Separation of training and validation data sets&lt;/h2&gt;

&lt;p&gt;The performance of a classifier can be determined by testing it with data sets it has not seen before. In many machine learning tasks this is done with randomly separated data rows into training and validation sets. As the login history of a user is not random but follows a certain pattern, only the most recent data is used for validation, while the historic data is used for training.&lt;/p&gt;

&lt;h2 id=&quot;building-the-input-layer&quot;&gt;Building the input layer&lt;/h2&gt;

&lt;p&gt;Another important consideration for the design of the machine learning application is the selection of a good input representation. The raw data is an UID string and an IPv4 string. These have to be converted to numeric values, while both keeping balance between the input values and making it possible for the neural net to learn the structure and hierarchy of IP addresses.&lt;/p&gt;

&lt;p&gt;This is the part where most effort went into but also where the biggest improvements in terms of classifier performance were made. I spare you the details of my failed attempts for a good input representation, but you can find it in the git history if you’re curious 😉.&lt;/p&gt;

&lt;p&gt;So far the best representation I have found is to hash the UID to a 16 bit binary vector. This lowers the value range while still having a relatively low conflict probability. The IP address is also represented as its 32bit binary vector. Combined, this makes for a 48bit input layer.&lt;/p&gt;

&lt;h2 id=&quot;sensible-training-parameters&quot;&gt;Sensible training parameters&lt;/h2&gt;

&lt;p&gt;Now that we have the training data and the correct representation we can have a close look at the parameters of a training. The multi layer perceptron of &lt;a href=&quot;https://php-ml.org/&quot;&gt;php-ml&lt;/a&gt; has &lt;a href=&quot;https://php-ml.readthedocs.io/en/latest/machine-learning/neural-network/multilayer-perceptron-classifier/#constructor-parameters&quot;&gt;these free parameters&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;layers&lt;/li&gt;
  &lt;li&gt;iterations (epochs)&lt;/li&gt;
  &lt;li&gt;learn rate&lt;/li&gt;
  &lt;li&gt;activation function&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ve ran numerous training runs with different sets of parameter values. The goal was to find something that has a high, but balanced precision and recall of logins classified as suspicious, while not consuming too much time to compute. The default set of parameters should also work relatively well for small, medium and large installations. After a few hundred training runs with many different combinations of parameter values I have found that 150 epochs, 14 layers and a learn rate of 7% to meet those requirements. I have also implemented a heuristic &lt;em&gt;simulated annealing&lt;/em&gt; algorithm that starts with random parameters and tests those iteratively with decreasingly modified random values within certain boundaries. These runs take a very long time as each of the parameter sets is used multiple times to compensate for the randomness of training a neural net. In the end the best solution found was usually also in the area of my handcrafted ones.&lt;/p&gt;

&lt;p&gt;In addition to the training parameters, the app is also configurable in the ratio of how much random and shuffled data to generate for the positive data available. As a sensible default the app takes 150% as many shuffled negative and 100% as many random samples as positive samples. With this configuration, precision and recall were the highest and the most balanced.&lt;/p&gt;

&lt;h2 id=&quot;keeping-the-model-up-to-date&quot;&gt;Keeping the model up-to-date&lt;/h2&gt;

&lt;p&gt;Training the model once does not do the job as users travel or simply get new IPs by their ISPs. But the admin actually does not even have to trigger any training because training is automated in a Nextcloud background job that runs once a day. This ensures that the model used is ready to distinguish login patterns of recently used IPs from the ones of new IP patterns. Depending on the instance size the training may take a few minutes to complete, but should not consume many resources on any reasonably powerful server.&lt;/p&gt;

&lt;h2 id=&quot;results&quot;&gt;Results&lt;/h2&gt;

&lt;p&gt;Precision and recall were already mentioned above. These binary metrics can tell how well the trained model might react to new login data. In this app we only care about the negative data sets, as in, how many of the suspicious logins are detected and how many of the detected are indeed from suspicious sources.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;precision(n)&lt;/strong&gt; is the ratio of truly suspicious logins among the set of (UID, IP) tuples classified as suspicious. Therefore it tells us how likely a suspicious login alert should alarm us (as opposed to false alarms).&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;recall(n)&lt;/strong&gt; is the ratio of detected suspicious logins among the set of all suspicious logins. It can therefore indicate how many of the logins from unknown/uncommon sources will be captured as such.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20190424_nextcloud_suspiciou_login_detection/admin_settings.png&quot; alt=&quot;Historic precision and recall of suspicious login detection on a small Nextcloud instance&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We have tested the app continuously on three instances and monitored the training results. The more stationary (no international travel, similar IPs assigned by ISPs and cell phone carriers) users of a Nextcloud are, the better the results. But also for larger instances with traveling users the results were always above 80% accuracy (both precision and recall).&lt;/p&gt;

&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;This is the first time I’m putting my knowledge about neural networks into a practical use case. So I’m very happy this turned out to work quite well so far and I hope this app will be used to protect the data of many Nextcloud instances.&lt;/p&gt;

&lt;p&gt;As always, the code is 100% open source, licensed under the GNU APGL. You can find the source code on &lt;a href=&quot;https://github.com/nextcloud/suspicious_login&quot;&gt;GitHub&lt;/a&gt;, where I hope to see your feedback, bug reports and questions.&lt;/p&gt;

&lt;p&gt;If you are new to Nextcloud, check out our &lt;a href=&quot;https://nextcloud.com/&quot;&gt;website&lt;/a&gt;!&lt;/p&gt;

&lt;h2 id=&quot;acknowledgement&quot;&gt;Acknowledgement&lt;/h2&gt;

&lt;p&gt;Many ideas for this app came from &lt;a href=&quot;https://aws.amazon.com/blogs/machine-learning/detect-suspicious-ip-addresses-with-the-amazon-sagemaker-ip-insights-algorithm/&quot;&gt;Amazon&lt;/a&gt; and &lt;a href=&quot;https://arxiv.org/pdf/1701.02145.pdf&quot;&gt;this paper, which also gives a great overview on the topic&lt;/a&gt;.&lt;/p&gt;
</description>
        <pubDate>Thu, 25 Apr 2019 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2019/04/25/nextcloud-suspicious-login-detection.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2019/04/25/nextcloud-suspicious-login-detection.html</guid>
        
        <category>nextcloud</category>
        
        <category>security</category>
        
        <category>machine learning</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>Using Nextcloud Logs as Sentry Breadcrumbs</title>
        <description>&lt;p&gt;The &lt;a href=&quot;https://sentry.io&quot;&gt;Sentry&lt;/a&gt; integration for &lt;a href=&quot;https://nextcloud.com/&quot;&gt;Nextcloud&lt;/a&gt; has been
available for more than a year now. During this year, we gradually improved the data that is
reported and the errors it can capture.&lt;/p&gt;

&lt;p&gt;For the new Nextcloud 15 we added support for Sentry’s breadcrumbs. These had been collected
by the Sentry client on the client side already. However, they needed special handling on the
server side to work with Nextcloud’s logging service. A small adjustment to the logger now
passes logged messages on to the “crash reporters” (an abstract term for integrations like
Sentry). The Sentry integration app then registers the messages as Sentry breadcrumbs.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20181211_nextcloud_log_sentr_breadcrumbs/breadcrumbs.png&quot; alt=&quot;&quot; /&gt;&lt;/p&gt;
</description>
        <pubDate>Tue, 11 Dec 2018 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2018/12/11/nextcloud-log-sentry-breadcrumbs.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2018/12/11/nextcloud-log-sentry-breadcrumbs.html</guid>
        
        <category>nextcloud</category>
        
        <category>sentry</category>
        
        <category>foss</category>
        
        
      </item>
    
      <item>
        <title>Mixing Nextcloud Globals into Vue</title>
        <description>&lt;p&gt;Nextcloud apps use global functions to access server APIs like the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt; function to translate
a given string. Within a Vue template, you can use this function like this:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;template&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;span&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;{{&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;myapp&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;Hello, {user}&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})}}&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/span&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/template&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;However, this won’t work. You will see a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TypeError: _vm.t is not a function&lt;/code&gt; error in your
browser’s console:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/20181023_mixing_nextcloud_globals_into_vue/console_error_small.png&quot; alt=&quot;TypeError: _vm.t is not a function&quot; /&gt;&lt;/p&gt;

&lt;p&gt;So far the easiest and cleanest way to fix this I have found is writing a tiny &lt;a href=&quot;https://vuejs.org/v2/guide/mixins.html&quot;&gt;Vue mixin&lt;/a&gt;:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// src/mixins/Nextcloud.js&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;t&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This mixin makes the global function &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;t&lt;/code&gt; available as instance method. It can be
used in an app globally via the entry script:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// src/main.js&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;vue&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Nextcloud&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;./mixins/Nextcloud&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;

&lt;span class=&quot;nx&quot;&gt;Vue&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;mixin&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Nextcloud&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Alternatively, it can also be applied to specific components only:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// src/components/MyComponent.js&lt;/span&gt;

&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;tempate&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;...&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/template&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;script&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;Nextcloud&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;../mixins/Nextcloud&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;

  &lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;props&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;dl&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;mixins&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;Nextcloud&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;sr&quot;&gt;/script&lt;/span&gt;&lt;span class=&quot;err&quot;&gt;&amp;gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h2 id=&quot;testing&quot;&gt;Testing&lt;/h2&gt;

&lt;p&gt;This trick is also handy for testing scenarios where the globals aren’t available. There
a slightly adjusted mixin can provide stubs for Nextcloud’s global functions:&lt;/p&gt;

&lt;div class=&quot;language-js highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;// src/tests/mixins/Nextcloud.js&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;default&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
  &lt;span class=&quot;na&quot;&gt;methods&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;na&quot;&gt;t&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;app&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&amp;gt;&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;str&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;hr /&gt;

&lt;p&gt;Update 2018-10-23: fixed typo.&lt;/p&gt;
</description>
        <pubDate>Mon, 22 Oct 2018 00:00:00 +0000</pubDate>
        <link>https://blog.wuc.me/2018/10/22/mixing-nextcloud-globals-into-vue.html</link>
        <guid isPermaLink="true">https://blog.wuc.me/2018/10/22/mixing-nextcloud-globals-into-vue.html</guid>
        
        <category>nextcloud</category>
        
        <category>vue</category>
        
        <category>javascript</category>
        
        <category>l10n</category>
        
        <category>foss</category>
        
        
      </item>
    
  </channel>
</rss>
