aboutsummaryrefslogtreecommitdiff
path: root/app/views
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2024-10-23 21:55:52 +0200
committerGravatar GitHub <noreply@github.com> 2024-10-23 21:55:52 +0200
commit7a5ce0fe20d63746b7f5b435ba5eef0a9b7db2d6 (patch)
tree090cff8c9852ecc4636feaa1c5a75304c23fad27 /app/views
parent60dd22d3b3916f5113954fc1472b1658c3c4245f (diff)
Web export SQLite (#6931)
* Web export SQLite https://github.com/FreshRSS/FreshRSS/discussions/6930 * Implement download * Fix operator precedence * Set Last-Modified * Sort by time, newest first * Fix Last-Modified * Use DateTimeInterface::RFC7231 * Add not_applicable message
Diffstat (limited to 'app/views')
-rw-r--r--app/views/importExport/index.phtml31
-rw-r--r--app/views/importExport/sqlite.phtml9
2 files changed, 39 insertions, 1 deletions
diff --git a/app/views/importExport/index.phtml b/app/views/importExport/index.phtml
index dfcdc8404..1f32acfcb 100644
--- a/app/views/importExport/index.phtml
+++ b/app/views/importExport/index.phtml
@@ -65,7 +65,7 @@
$select_args = ' size="' . min(10, count($this->feeds)) . '" multiple="multiple"';
}
?>
- <select name="export_feeds[]"<?= $select_args ?> size="10">
+ <select name="export_feeds[]"<?= $select_args ?>>
<?= extension_loaded('zip') ? '' : '<option></option>' ?>
<?php foreach ($this->feeds as $feed) { ?>
<option value="<?= $feed->id() ?>"><?= $feed->name() ?></option>
@@ -81,4 +81,33 @@
</div>
</form>
<?php } ?>
+
+ <h2><?= _t('sub.import_export.export.sqlite') ?></h2>
+ <?php if (count($this->sqliteArchives ?? []) === 0): ?>
+ <p class="alert alert-warn">
+ <?= _t('gen.short.not_applicable') ?>
+ </p>
+ <?php else: ?>
+ <form method="post" action="<?= _url('importExport', 'sqlite') ?>">
+ <input type="hidden" name="_csrf" value="<?= FreshRSS_Auth::csrfToken() ?>" />
+ <div class="form-group">
+ <div class="group-controls">
+ <select name="sqlite">
+ <?php foreach ($this->sqliteArchives ?? [] as $sqliteArchive): ?>
+ <option value="<?= htmlspecialchars($sqliteArchive['name'], ENT_COMPAT, 'UTF-8') ?>">
+ <?= htmlspecialchars($sqliteArchive['name'], ENT_NOQUOTES, 'UTF-8') ?>
+ <small>(<?= format_bytes($sqliteArchive['size']) ?> ยท <?= date('c', $sqliteArchive['mtime']) ?>)</small>
+ </option>
+ <?php endforeach; ?>
+ </select>
+ </div>
+ </div>
+
+ <div class="form-group form-actions">
+ <div class="group-controls">
+ <button type="submit" class="btn btn-important"><?= _t('gen.action.download') ?></button>
+ </div>
+ </div>
+ </form>
+ <?php endif; ?>
</main>
diff --git a/app/views/importExport/sqlite.phtml b/app/views/importExport/sqlite.phtml
new file mode 100644
index 000000000..8c9adcab1
--- /dev/null
+++ b/app/views/importExport/sqlite.phtml
@@ -0,0 +1,9 @@
+<?php
+declare(strict_types=1);
+/** @var FreshRSS_View $this */
+header('Content-Type: application/vnd.sqlite3');
+header('Content-Disposition: attachment; filename="' . basename($this->sqlitePath) . '"');
+header('Cache-Control: private, no-store, max-age=0');
+header('Last-Modified: ' . gmdate(DateTimeInterface::RFC7231, @filemtime($this->sqlitePath) ?: 0));
+header('Content-Length: ' . (@filesize($this->sqlitePath) ?: 0));
+readfile($this->sqlitePath);