summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-02-06 19:21:12 +0200
committerLars Wirzenius <liw@liw.fi>2023-02-06 19:21:12 +0200
commitbe91a614b07e1210153d350ee692ef57bf95b15b (patch)
tree81afd59bb684f1f696e5e68eebb296ceb6ec5fc7
parentdc10792ba721452efc2a377249c6c5b2d365cf26 (diff)
downloadriki-be91a614b07e1210153d350ee692ef57bf95b15b.tar.gz
feat: allow link() in pagespec to contain a glob
Sponsored-by: author
-rw-r--r--src/pagespec.lalrpop2
-rw-r--r--src/pagespec.rs6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/pagespec.lalrpop b/src/pagespec.lalrpop
index bc07744..ccee2c4 100644
--- a/src/pagespec.lalrpop
+++ b/src/pagespec.lalrpop
@@ -9,7 +9,7 @@ pub Expr: Box<Expr> = {
Term: Box<Expr> = {
Glob => Box::new(Expr::Glob(<>)),
- "link" "(" "." ")" => Box::new(Expr::LinksHereFunc),
+ "link" "(" <g:Glob> ")" => Box::new(Expr::LinksHereFunc(<>)),
"page" "(" <g:Glob> ")" => Box::new(Expr::PageFunc(<>)),
"!" <t:Term> => Box::new(Expr::Negate(t)),
"(" <e:Expr> ")" => e,
diff --git a/src/pagespec.rs b/src/pagespec.rs
index e3f617d..7af2acd 100644
--- a/src/pagespec.rs
+++ b/src/pagespec.rs
@@ -64,7 +64,7 @@ pub enum PageSpecError {
#[derive(Debug)]
pub enum Expr {
Glob(String),
- LinksHereFunc,
+ LinksHereFunc(String),
PageFunc(String),
Negate(Box<Expr>),
Op(Box<Expr>, OpCode, Box<Expr>),
@@ -75,7 +75,7 @@ impl Expr {
trace!("Expr::matches: path={:?} self={:?}", path, self);
match self {
Self::Glob(glob) => glob_matches(glob, path),
- Self::LinksHereFunc => links_here(site, container, path), // FIXME: check its page
+ Self::LinksHereFunc(glob) => links_here(site, container, path, glob),
Self::PageFunc(glob) => page_matches(site, container, glob, path), // FIXME: check its page
Self::Negate(expr) => !expr.matches(site, container, path),
Self::Op(left, op, right) => match op {
@@ -148,7 +148,7 @@ fn glob_matches_helper(mut glob: &[char], mut path: &[char]) -> bool {
glob.is_empty() && path.is_empty()
}
-fn links_here(site: &Site, container: &Path, path: &str) -> bool {
+fn links_here(site: &Site, container: &Path, path: &str, _glob: &str) -> bool {
trace!(
"links_here: container={} path={:?}",
container.display(),