mirror of
https://github.com/YGGverse/pulsarss.git
synced 2026-03-31 09:05:29 +00:00
add custom index filename support
This commit is contained in:
parent
86b5d41aec
commit
dbd9fa3960
3 changed files with 11 additions and 11 deletions
|
|
@ -20,7 +20,7 @@ cargo install pulsarss
|
||||||
## Launch
|
## Launch
|
||||||
|
|
||||||
``` bash
|
``` bash
|
||||||
pulsarss --source https://path/to/feed.rss --index
|
pulsarss --source https://path/to/feed.rss
|
||||||
```
|
```
|
||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
@ -28,7 +28,7 @@ pulsarss --source https://path/to/feed.rss --index
|
||||||
* `source`, `s` - RSS feed source (required)
|
* `source`, `s` - RSS feed source (required)
|
||||||
* `target`, `t` - Destination directory (`public` by default)
|
* `target`, `t` - Destination directory (`public` by default)
|
||||||
* `update`, `u` - Update timeout in seconds (`60` by default)
|
* `update`, `u` - Update timeout in seconds (`60` by default)
|
||||||
* `index`, `i` - Generate `index.gmi` files (`false` by default)
|
* `index`, `i` - Generate index files (`index.gmi` by default, empty to disable)
|
||||||
* `limit`, `l` - Limit channel items (unlimited by default)
|
* `limit`, `l` - Limit channel items (unlimited by default)
|
||||||
* `output`, `o` - Print output (`dw` by default):
|
* `output`, `o` - Print output (`dw` by default):
|
||||||
* `d` - debug
|
* `d` - debug
|
||||||
|
|
@ -49,7 +49,7 @@ After=network.target
|
||||||
Type=simple
|
Type=simple
|
||||||
User=pulsarss
|
User=pulsarss
|
||||||
Group=pulsarss
|
Group=pulsarss
|
||||||
ExecStart=pulsarss -is https://path/to/feed.rss
|
ExecStart=pulsarss -s https://path/to/feed.rss
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@ use clap::Parser;
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
pub struct Argument {
|
pub struct Argument {
|
||||||
/// Generate `index.gmi` files (`false` by default)
|
/// Generate index files (`index.gmi` by default, empty to disable)
|
||||||
#[arg(short, long, default_value_t = false)]
|
#[arg(short, long, default_value_t = String::from("index.gmi"))]
|
||||||
pub index: bool,
|
pub index: String,
|
||||||
|
|
||||||
/// Limit channel items (unlimited by default)
|
/// Limit channel items (unlimited by default)
|
||||||
#[arg(short, long, default_value_t = 0)]
|
#[arg(short, long, default_value_t = 0)]
|
||||||
|
|
|
||||||
10
src/main.rs
10
src/main.rs
|
|
@ -94,14 +94,14 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
||||||
|
|
||||||
File::create(destination.item())?.write_all(data.join("\n\n").as_bytes())?;
|
File::create(destination.item())?.write_all(data.join("\n\n").as_bytes())?;
|
||||||
|
|
||||||
if argument.index {
|
if !argument.index.is_empty() {
|
||||||
index.insert(destination.path); // request `index.gmi` update
|
index.insert(destination.path); // request index file update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// renew pending `index.gmi` files on items crawl completed
|
// renew pending index files on items crawl completed
|
||||||
for path in index {
|
for path in index {
|
||||||
let subject = format!("{path}index.gmi");
|
let subject = format!("{path}{}", argument.index);
|
||||||
|
|
||||||
let mut index = File::create(&subject)?;
|
let mut index = File::create(&subject)?;
|
||||||
let mut data = Vec::with_capacity(argument.limit);
|
let mut data = Vec::with_capacity(argument.limit);
|
||||||
|
|
@ -110,7 +110,7 @@ fn crawl(argument: &Argument, output: &Output) -> Result<(), Box<dyn Error>> {
|
||||||
for file in read_dir(&path)? {
|
for file in read_dir(&path)? {
|
||||||
let name = file?.file_name().into_string().unwrap();
|
let name = file?.file_name().into_string().unwrap();
|
||||||
|
|
||||||
if name == "index.gmi" {
|
if name == argument.index {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue