Skip to content

Commit 3e5cda6

Browse files
committed
Merge pull request #13 from BafS/dev
Ready for version 0.6.0
2 parents a00198d + 07a573c commit 3e5cda6

40 files changed

+954
-991
lines changed

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,14 @@ Thumbs.db
2828
*.paw
2929
*.phar
3030
*.exe
31+
doc/
3132

3233
# Jekyll
3334
_site
3435
.sass-cache
3536
.jekyll-metadata
37+
/api/*
38+
39+
# Npm
40+
node_modules/
3641

Parvula/Core/Container.php

-137
This file was deleted.

Parvula/Core/FilesSystem.php

+14
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function isDir($dirname) {
5656
* @param callable ($fn) Apply function to file data (\SplFileInfo $file, string $data)
5757
* @param boolean ($eval) Evaluate PHP
5858
* @throws IOException If the file does not exists
59+
* @throws IOException If the file is empty
5960
* @return mixed File data
6061
*/
6162
public function read($filename, callable $fn = null, $eval = false) {
@@ -72,6 +73,9 @@ public function read($filename, callable $fn = null, $eval = false) {
7273
$data = ob_get_clean();
7374
} else {
7475
$file = $fileInfo->openFile('r');
76+
if ($file->getSize() === 0) {
77+
throw new IOException("File `{$filename}` is empty");
78+
}
7579
$data = $file->fread($file->getSize());
7680
}
7781
}
@@ -204,6 +208,16 @@ public function index($dir = '', callable $fn = null, $filter = null) {
204208
return $this->indexAll($dir, $fn, $filter);
205209
}
206210

211+
/**
212+
* Get file modification time
213+
*
214+
* @param string $filename
215+
* @return int Timestamp
216+
*/
217+
public function modificationTime($filename = '') {
218+
return filemtime($this->workingDirectory . $filename);
219+
}
220+
207221
/**
208222
* Get working directory
209223
*

Parvula/Core/Model/Mapper/Pages.php

+22
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ public function visibility($visible) {
109109
});
110110
}
111111

112+
/**
113+
* Show pages without a parent (the 'root' pages)
114+
*
115+
* @return Pages
116+
*/
117+
public function withoutParent() {
118+
return $this->filter(function (Page $page) {
119+
return (bool) !$page->get('parent');
120+
});
121+
}
122+
123+
/**
124+
* Show pages with a parent (the children pages)
125+
*
126+
* @return Pages
127+
*/
128+
public function withParent() {
129+
return $this->filter(function (Page $page) {
130+
return (bool) $page->get('parent');
131+
});
132+
}
133+
112134
/**
113135
* Filter pages
114136
*

0 commit comments

Comments
 (0)