Skip to content

Commit

Permalink
new: Provide a What's new? page
Browse files Browse the repository at this point in the history
  • Loading branch information
marienfressinaud committed Oct 4, 2022
1 parent 6bfd55a commit 14ffb40
Show file tree
Hide file tree
Showing 16 changed files with 139 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ In development, commands `make start` and `make stop` have been renamed to
`make docker-start` and `make docker-stop`. You’ll also have to rebuild the
bundler image with `make docker-build`.

You can set the new `APP_FEED_WHAT_IS_NEW` environment variable to change the
feed served by the “What’s new?” link (in “Help & support”).

## 2022-09-23 - v0.51

### Improvements
Expand Down
4 changes: 4 additions & 0 deletions configuration/environment_development.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
'media_path' => $dotenv->pop('APP_MEDIA_PATH', $app_path . '/public/media'),
'demo' => filter_var($dotenv->pop('APP_DEMO', false), FILTER_VALIDATE_BOOLEAN),
'registrations_opened' => filter_var($dotenv->pop('APP_OPEN_REGISTRATIONS', true), FILTER_VALIDATE_BOOLEAN),
'what_is_new_feed' => $dotenv->pop(
'APP_FEED_WHAT_IS_NEW',
'https://github.com/flusio/flusio/releases.atom'
),
'subscriptions_enabled' => $subscriptions_host !== null,
'subscriptions_host' => $subscriptions_host,
'subscriptions_private_key' => $dotenv->pop('APP_SUBSCRIPTIONS_PRIVATE_KEY'),
Expand Down
4 changes: 4 additions & 0 deletions configuration/environment_production.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
'media_path' => $dotenv->pop('APP_MEDIA_PATH', $app_path . '/public/media'),
'demo' => filter_var($dotenv->pop('APP_DEMO', false), FILTER_VALIDATE_BOOLEAN),
'registrations_opened' => filter_var($dotenv->pop('APP_OPEN_REGISTRATIONS', true), FILTER_VALIDATE_BOOLEAN),
'what_is_new_feed' => $dotenv->pop(
'APP_FEED_WHAT_IS_NEW',
'https://github.com/flusio/flusio/releases.atom'
),
'subscriptions_enabled' => $subscriptions_host !== null,
'subscriptions_host' => $subscriptions_host,
'subscriptions_private_key' => $dotenv->pop('APP_SUBSCRIPTIONS_PRIVATE_KEY'),
Expand Down
4 changes: 4 additions & 0 deletions configuration/environment_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
'media_path' => $media_directory,
'demo' => false,
'registrations_opened' => true,
'what_is_new_feed' => $dotenv->pop(
'APP_FEED_WHAT_IS_NEW',
'https://github.com/flusio/flusio/releases.atom'
),
'subscriptions_enabled' => false, // should be enable on a case-by-case basis
'subscriptions_host' => $subscriptions_host,
'subscriptions_private_key' => $dotenv->pop('APP_SUBSCRIPTIONS_PRIVATE_KEY'),
Expand Down
13 changes: 13 additions & 0 deletions docs/production.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,19 @@ CLI:
flusio# sudo -u www-data php cli users create --username=Abby --email=email@example.com --password=secret
```

## Optional: Change the “What’s new?” feed

In the “Help & support” page, there’s a link named “What’s new?”. It
automatically redirects to the feed of the [flusio releases](https://github.com/flusio/flusio/releases)
on GitHub.

You can set a custom feed in your `.env` file (if you offer a service based on
flusio for instance, and that you have a blog explaining the latest changes):

```dotenv
APP_FEED_WHAT_IS_NEW=https://example.com/your/feed.xml
```

## Optional: Change CLI default locale

You can force the locale of CLI commands by setting the `CLI_LOCALE`
Expand Down
4 changes: 4 additions & 0 deletions env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ SMTP_SECURE=tls
# demo account credentials
# APP_DEMO=true

# Uncomment and set to the desired feed. It will change which feed is served by
# the "What’s new?" link.
# APP_FEED_WHAT_IS_NEW=https://github.com/flusio/flusio/releases.atom

# These two variables enable the subscriptions mechanism. It's very likely you
# will not have to set them since it's designed for the service at https://flus.fr
# only.
Expand Down
Binary file modified locales/fr_FR/LC_MESSAGES/main.mo
Binary file not shown.
20 changes: 12 additions & 8 deletions locales/fr_FR/LC_MESSAGES/main.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: flusio\n"
"POT-Creation-Date: 2022-10-04 14:33+0200\n"
"PO-Revision-Date: 2022-10-04 14:36+0200\n"
"POT-Creation-Date: 2022-10-04 20:31+0200\n"
"PO-Revision-Date: 2022-10-04 20:31+0200\n"
"Last-Translator: Marien Fressinaud <dev@marienfressinaud.fr>\n"
"Language-Team: \n"
"Language: fr_FR\n"
Expand All @@ -15,7 +15,7 @@ msgstr ""
"X-Poedit-KeywordsList: _f;_n:1,2;_nf:1,2\n"
"X-Poedit-SearchPath-0: .\n"

#: assets/javascripts/controllers/back_button_controller.js:39
#: assets/javascripts/controllers/back_button_controller.js:47
#: views/_layouts/connected.phtml:217
#: views/_layouts/connected_blocked.phtml:176
#: views/_layouts/not_connected.phtml:147
Expand Down Expand Up @@ -45,7 +45,7 @@ msgstr "Cacher"
msgid "Show"
msgstr "Afficher"

#: controllers/Collections.php:99 controllers/Collections.php:307
#: controllers/Collections.php:100 controllers/Collections.php:308
#: controllers/Feeds.php:116 controllers/Groups.php:90
#: controllers/Links.php:222 controllers/News.php:75
#: controllers/Passwords.php:88 controllers/Passwords.php:191
Expand All @@ -58,7 +58,7 @@ msgstr "Afficher"
#: controllers/collections/Shares.php:107
#: controllers/collections/Shares.php:230 controllers/links/Messages.php:73
#: controllers/links/Repairing.php:109 controllers/links/Searches.php:106
#: controllers/my/Account.php:103 controllers/my/Preferences.php:76
#: controllers/my/Account.php:103 controllers/my/Preferences.php:77
#: controllers/my/Profile.php:72 controllers/my/Security.php:79
#: controllers/my/Security.php:150 controllers/my/Subscription.php:74
#: controllers/my/Validation.php:132
Expand All @@ -67,11 +67,11 @@ msgstr ""
"Une vérification de sécurité a échoué : vous devriez essayer de resoumettre "
"le formulaire."

#: controllers/Collections.php:112 controllers/Collections.php:322
#: controllers/Collections.php:113 controllers/Collections.php:323
msgid "One of the associated topic doesn’t exist."
msgstr "L’une des thématiques associées n’existe pas."

#: controllers/Collections.php:382 controllers/Exportations.php:61
#: controllers/Collections.php:383 controllers/Exportations.php:61
#: controllers/Groups.php:161 controllers/Importations.php:48
#: controllers/Links.php:357 controllers/Links.php:404
#: controllers/Messages.php:93 controllers/Messages.php:141
Expand Down Expand Up @@ -653,7 +653,7 @@ msgid "Choose your language"
msgstr "Choisissez votre langue"

#: views/_layouts/not_connected.phtml:160 views/pages/about.phtml:3
#: views/pages/about.phtml:11 views/support/show.phtml:103
#: views/pages/about.phtml:11 views/support/show.phtml:109
#, php-format
msgid "About %s"
msgstr "À propos de %s"
Expand Down Expand Up @@ -2642,6 +2642,10 @@ msgstr "Plus d’aide"
msgid "Start the onboarding again"
msgstr "Recommencer l’introduction"

#: views/support/show.phtml:103
msgid "What’s new?"
msgstr "Quoi de neuf ?"

#: views/topics/show.phtml:13
#, php-format
msgid "The collections about %s, on %s."
Expand Down
2 changes: 1 addition & 1 deletion public/static/icons.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public static function load()
$router->addRoute('get', '/', 'Pages#home', 'home');
$router->addRoute('get', '/terms', 'Pages#terms', 'terms');
$router->addRoute('get', '/about', 'Pages#about', 'about');
$router->addRoute('get', '/about/new', 'Feeds#whatIsNew', 'what is new');
$router->addRoute('get', '/addons', 'Pages#addons', 'addons');
$router->addRoute('get', '/robots.txt', 'Pages#robots', 'robots.txt');
$router->addRoute('get', '/app.webmanifest', 'Pages#webmanifest', 'webmanifest');
Expand Down
1 change: 1 addition & 0 deletions src/assets/icons/bundle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion src/assets/javascripts/controllers/back_button_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ export default class extends Controller {
backHistory = [];
}

if (this.trackValue) {
if (
this.trackValue &&
// This URL is automatically redirected to /collections/:id.
// Unfortunately, because how Turbo works, both URLs call this
// initialize() method and add them to the history. I don't have a
// simple and clean solution on the backend-side to solve this
// issue, so I use this little hack to not track the /about/new URL.
window.location.pathname !== '/about/new'
) {
// Stack the current path at the top of the history only if we’re
// asked to track the current page
const currentPath = window.location.pathname + window.location.search;
Expand Down
4 changes: 4 additions & 0 deletions src/assets/stylesheets/components/groupnavs.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
background-image: url("../../icons/info.svg");
}

.groupnav__item--whats-new .groupnav__anchor {
background-image: url("../../icons/bundle.svg");
}

.groupnav__item--onboarding .groupnav__anchor {
background-image: url("../../icons/undo.svg");
}
Expand Down
28 changes: 28 additions & 0 deletions src/controllers/Feeds.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,34 @@ public function create($request)
return Response::redirect('collection', ['id' => $feed->id]);
}

/**
* Redirect to the "what is new" feed.
*
* @response 302 /collections/:id
*/
public function whatIsNew()
{
$support_user = models\User::supportUser();
$feed_url = \Minz\Configuration::$application['what_is_new_feed'];

$feed = models\Collection::findBy([
'type' => 'feed',
'feed_url' => $feed_url,
'user_id' => $support_user->id,
]);
if (!$feed) {
$feed_fetcher_service = new services\FeedFetcher([
'timeout' => 10,
'rate_limit' => false,
]);

$feed = models\Collection::initFeed($support_user->id, $feed_url);
$feed_fetcher_service->fetch($feed);
}

return Response::redirect('collection', ['id' => $feed->id]);
}

/**
* Return a XSL file to style the feeds.
*
Expand Down
6 changes: 6 additions & 0 deletions src/views/support/show.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@
</a>
</li>

<li class="groupnav__item groupnav__item--whats-new">
<a class="groupnav__anchor" href="<?= url('what is new') ?>">
<?= _('What’s new?') ?>
</a>
</li>

<li class="groupnav__item groupnav__item--about">
<a class="groupnav__anchor" href="<?= url('about') ?>">
<?= _f('About %s', $brand) ?>
Expand Down
45 changes: 45 additions & 0 deletions tests/controllers/FeedsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,49 @@ public function testCreateFailsIfNoFeedsCanBeFound()
$this->assertResponseContains($response, 'There is no valid feeds at this address');
$this->assertSame(0, models\Collection::countBy(['type' => 'feed']));
}

public function testWhatIsNewRedirectsToCollection()
{
$support_user = models\User::supportUser();
$feed_url = 'https://github.com/flusio/flusio/releases.atom';
$collection_id = $this->create('collection', [
'user_id' => $support_user->id,
'type' => 'feed',
'feed_url' => $feed_url,
]);

$response = $this->appRun('get', '/about/new');

$this->assertResponseCode($response, 302, "/collections/{$collection_id}");
}

public function testWhatIsNewCreatesFeedIfItDoesNotExist()
{
$support_user = models\User::supportUser();
$feed_url = 'https://github.com/flusio/flusio/releases.atom';
$this->mockHttpWithFixture(
$feed_url,
'responses/flus.fr_carnet_feeds_all.atom.xml'
);
// The FeedFetcher will call these URLs as well because the feed URL is
// mocked with the feed of flus.fr/carnet.
$this->mockHttpWithFixture(
'https://flus.fr/carnet/',
'responses/flus.fr_carnet_index.html'
);
$this->mockHttpWithFile(
'https://flus.fr/carnet/card.png',
'public/static/og-card.png'
);

$this->assertSame(0, models\Collection::count());

$response = $this->appRun('get', '/about/new');

$this->assertSame(1, models\Collection::count());

$collection = models\Collection::take();
$this->assertSame($feed_url, $collection->feed_url);
$this->assertResponseCode($response, 302, "/collections/{$collection->id}");
}
}

0 comments on commit 14ffb40

Please sign in to comment.