projects
/
mdref
/
mdref
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
|
github
raw
|
inline
| side by side
lift max-width limitation
[mdref/mdref]
/
mdref
/
Repo.php
diff --git
a/mdref/Repo.php
b/mdref/Repo.php
index f59a82e7b387178621498dadad2ac6cfe1b5daaa..8f4b830295a138f87d50222bc2bb27b7e6ddf59f 100644
(file)
--- a/
mdref/Repo.php
+++ b/
mdref/Repo.php
@@
-12,19
+12,19
@@
class Repo implements \IteratorAggregate {
* @var string
*/
private $name;
* @var string
*/
private $name;
-
+
/**
* The path to the repository
* @var string
*/
private $path;
/**
* The path to the repository
* @var string
*/
private $path;
-
+
/**
* The edit url template
* @var string
*/
private $edit;
/**
* The edit url template
* @var string
*/
private $edit;
-
+
/**
* Path to the repository containing the name.mdref file
* @param string $path
/**
* Path to the repository containing the name.mdref file
* @param string $path
@@
-36,12
+36,12
@@
class Repo implements \IteratorAggregate {
sprintf("Not a reference, could not find '*.mdref': '%s'",
$path));
}
sprintf("Not a reference, could not find '*.mdref': '%s'",
$path));
}
-
+
$this->path = realpath($path);
$this->name = basename($mdref, ".mdref");
$this->edit = trim(file_get_contents($mdref));
}
$this->path = realpath($path);
$this->name = basename($mdref, ".mdref");
$this->edit = trim(file_get_contents($mdref));
}
-
+
/**
* Get the repository's name
* @return string
/**
* Get the repository's name
* @return string
@@
-49,7
+49,7
@@
class Repo implements \IteratorAggregate {
public function getName() {
return $this->name;
}
public function getName() {
return $this->name;
}
-
+
/**
* Get the path of the repository or a file in it
* @param string $file
/**
* Get the path of the repository or a file in it
* @param string $file
@@
-58,7
+58,7
@@
class Repo implements \IteratorAggregate {
public function getPath($file = "") {
return $this->path . "/$file";
}
public function getPath($file = "") {
return $this->path . "/$file";
}
-
+
/**
* Get the edit url for a ref entry
* @param string $entry
/**
* Get the edit url for a ref entry
* @param string $entry
@@
-67,15
+67,19
@@
class Repo implements \IteratorAggregate {
public function getEditUrl($entry) {
return sprintf($this->edit, $entry);
}
public function getEditUrl($entry) {
return sprintf($this->edit, $entry);
}
-
+
/**
* Get the file path of an entry in this repo
* @param string $entry
* @return string file path
*/
public function hasEntry($entry, &$canonical = null) {
/**
* Get the file path of an entry in this repo
* @param string $entry
* @return string file path
*/
public function hasEntry($entry, &$canonical = null) {
- $file = $this->getPath("$entry.md");
- if (is_file($file)) {
+ $trim = rtrim($entry, "/");
+ $file = $this->getPath("$trim.md");
+ if (is_file($file)) {
+ if ($trim !== $entry) {
+ $canonical = $trim;
+ }
return $file;
}
$file = $this->getPath($this->getName()."/$entry.md");
return $file;
}
$file = $this->getPath($this->getName()."/$entry.md");
@@
-84,7
+88,7
@@
class Repo implements \IteratorAggregate {
return $file;
}
}
return $file;
}
}
-
+
/**
* Get the canonical entry name of a file in this repo
* @param string $file
/**
* Get the canonical entry name of a file in this repo
* @param string $file
@@
-97,16
+101,16
@@
class Repo implements \IteratorAggregate {
if (!strncmp($file, $path, $plen)) {
$dirname = dirname(substr($file, $plen));
$basename = basename($file, ".md");
if (!strncmp($file, $path, $plen)) {
$dirname = dirname(substr($file, $plen));
$basename = basename($file, ".md");
-
+
if ($dirname === ".") {
return $basename;
}
if ($dirname === ".") {
return $basename;
}
-
+
return $dirname . "/". $basename;
}
}
}
return $dirname . "/". $basename;
}
}
}
-
+
/**
* Get an Entry instance
* @param string $entry
/**
* Get an Entry instance
* @param string $entry
@@
-116,7
+120,7
@@
class Repo implements \IteratorAggregate {
public function getEntry($entry) {
return new Entry($entry, $this);
}
public function getEntry($entry) {
return new Entry($entry, $this);
}
-
+
/**
* Get the root Entry instance
* @return \mdref\Entry
/**
* Get the root Entry instance
* @return \mdref\Entry
@@
-124,7
+128,7
@@
class Repo implements \IteratorAggregate {
public function getRootEntry() {
return new Entry($this->name, $this);
}
public function getRootEntry() {
return new Entry($this->name, $this);
}
-
+
/**
* Implements \IteratorAggregate
* @return \mdref\Tree
/**
* Implements \IteratorAggregate
* @return \mdref\Tree