Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pico 1.0 #252

Merged
merged 120 commits into from
Nov 6, 2015
Merged
Changes from 1 commit
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
adc3562
Remove index.html
PhrozenByte Aug 28, 2015
c496297
Class files should exactly match the class name
PhrozenByte Aug 28, 2015
284e0ce
Move constants to global.php
PhrozenByte Aug 28, 2015
92c307d
Pico 1.0
PhrozenByte Aug 28, 2015
cd14582
Remove pull request message
PhrozenByte Aug 28, 2015
43a7540
Add IPicoPlugin
PhrozenByte Aug 28, 2015
07ae267
Add AbstractPicoPlugin
PhrozenByte Aug 28, 2015
b347790
Replace Pico_Plugin with DummyPlugin
PhrozenByte Aug 28, 2015
fd1b94e
Update composer.json
PhrozenByte Aug 28, 2015
70316ec
Add PicoDeprecated, PicoParsePagesContent, PicoExcerpt
PhrozenByte Aug 28, 2015
144939b
Update config.php.template
PhrozenByte Aug 28, 2015
39e1d78
Update sample content
PhrozenByte Aug 28, 2015
5438fdb
Rename index.html of default theme to index.twig; Update template
PhrozenByte Aug 28, 2015
c44afd3
Update .htaccess
PhrozenByte Aug 28, 2015
df10d60
Fixing paths in global.php
PhrozenByte Aug 30, 2015
5eed6d0
Add missing update of index.twig
PhrozenByte Aug 30, 2015
5338223
Workaround for webservers omitting QUERY_STRING
PhrozenByte Aug 30, 2015
a83b01e
Access plugins by class name, not file name
PhrozenByte Sep 6, 2015
71e7da2
Various fixes
PhrozenByte Sep 13, 2015
5731ede
Allow omitting config/config.php; Fix write context on return value
PhrozenByte Sep 14, 2015
4821454
Declare in config/config.php.template to prevent a E_NOTICE
PhrozenByte Sep 14, 2015
70f187f
Rename IPicoPlugin to PicoPluginInterface
PhrozenByte Sep 15, 2015
f76a0b7
Use v0.7 releases of erusev/parsedown-extra
PhrozenByte Sep 15, 2015
5533b07
Re-add lost PicoPluginInterface
PhrozenByte Sep 15, 2015
a7fd853
Add striptags filter to description meta header
PhrozenByte Sep 17, 2015
a5755b0
Fix deprecated get_page_data and get_pages events
PhrozenByte Sep 28, 2015
13a50c7
Don't change $pageData['id'], add ~dup1 to the array key only
PhrozenByte Sep 28, 2015
8d88863
Fix whitespace
PhrozenByte Sep 28, 2015
5e77d86
Remove twig cache dir
PhrozenByte Sep 28, 2015
fc7632b
Overhaul init of Pico
PhrozenByte Oct 1, 2015
cdef7a6
Explicitly treat relative paths to be relative to Picos root dir
PhrozenByte Oct 1, 2015
95db5ba
Drop inaccessible pages
PhrozenByte Oct 1, 2015
45815e2
Don't read file contents of inaccessible pages
PhrozenByte Oct 1, 2015
fd64e4f
Add a exception to alpha sorting: List index files first
PhrozenByte Oct 1, 2015
012dffa
Fix #257
PhrozenByte Oct 1, 2015
fbb744d
Deny access to config, content, content-sample, lib and vendor dirs
PhrozenByte Oct 1, 2015
241a529
Update inline code comments
PhrozenByte Oct 1, 2015
9be23de
Require PHP >= 5.3.6 until erusev/parsedown-extra#75 is solved
PhrozenByte Oct 2, 2015
00f76d1
Update README.md
PhrozenByte Oct 3, 2015
7698f18
Merge branch 'master' into pico1.0
PhrozenByte Oct 3, 2015
fa024ce
Fix README.md formatting
PhrozenByte Oct 3, 2015
ab89945
Improve README.md formatting; Run PHP web server on localhost only
PhrozenByte Oct 3, 2015
3a4721a
SCANDIR_SORT_* constants are available since PHP 5.4
PhrozenByte Oct 4, 2015
3f7b099
Declare undefined $plugins variable
PhrozenByte Oct 4, 2015
77f9390
Support per-directory 404.md files
PhrozenByte Oct 4, 2015
9aa62b4
Improve method docs of Pico::load404Content()
PhrozenByte Oct 4, 2015
ef1a9e0
Improve README.md
PhrozenByte Oct 4, 2015
2e15e11
Define deprecated constants before evaluating the config.php in Picos…
PhrozenByte Oct 4, 2015
006afa5
Update changelog.txt
PhrozenByte Oct 4, 2015
27d6946
Fix code formatting
PhrozenByte Oct 4, 2015
79e2dac
Fix method docs typo
PhrozenByte Oct 4, 2015
4f1e866
Cast AbstractPicoPlugin::$dependsOn to array
PhrozenByte Oct 4, 2015
9d518fd
Move sorting of $pages from Pico::getPages() to Pico::sortPages()
PhrozenByte Oct 4, 2015
46ef631
Support $config['<plugin name>']['enabled'] option
PhrozenByte Oct 4, 2015
1cbf48a
Split PicoDeprecated::onConfigLoaded() into multiple methods
PhrozenByte Oct 4, 2015
7537159
Remove the need to register headers during onMetaHeaders()
PhrozenByte Oct 4, 2015
7aa199d
Update changelog.txt for 7537159
PhrozenByte Oct 4, 2015
1419cf1
Add Pico::setConfig() method
PhrozenByte Oct 6, 2015
04a1c60
Update changelog.txt for 1419cf1
PhrozenByte Oct 6, 2015
b09433a
Allow multiple calls to Pico::setConfig()
PhrozenByte Oct 6, 2015
7c5f371
Use PSR-0 autoload
PhrozenByte Oct 8, 2015
40dbd0e
Update Picos inline user docs
PhrozenByte Oct 8, 2015
b46ed05
Let users know about Twigs link filter
PhrozenByte Oct 9, 2015
3336fb7
fix spelling
theshka Oct 9, 2015
fe83d1f
fix spelling
theshka Oct 9, 2015
01122f2
fix spelling
theshka Oct 9, 2015
8380b54
fix spelling
theshka Oct 9, 2015
132399f
add comments/in-line docs
theshka Oct 9, 2015
aec024a
fix spelling
theshka Oct 9, 2015
15515ff
Fix typo/formatting
PhrozenByte Oct 9, 2015
9cdd34e
Change content order, add Customization section
PhrozenByte Oct 9, 2015
4171f9a
Move URL Rewriting to Config section
PhrozenByte Oct 9, 2015
92af554
Improve inline code comments; preparing use of phpDocumentor
PhrozenByte Oct 27, 2015
a654b15
phpDocumentor 2.8.5 currently doesn't support the Generic notations
PhrozenByte Oct 27, 2015
de6b3a7
Fix Markdown %meta.*% replacement
PhrozenByte Oct 28, 2015
9e2604a
Prevent content_dir breakouts using malicious request URLs
PhrozenByte Oct 28, 2015
647a7b5
Trap empty $requestFileParts
PhrozenByte Oct 28, 2015
3e0161b
Create .travis.yml
dav-m85 Oct 28, 2015
d3a1308
Update .travis.yml
PhrozenByte Oct 28, 2015
efcbbb8
Update .travis.yml
PhrozenByte Oct 28, 2015
a068a1f
Update changelog.txt
PhrozenByte Oct 28, 2015
360e7ab
Update .travis.yml
PhrozenByte Oct 28, 2015
43f9590
Update .travis.yml
PhrozenByte Oct 28, 2015
a068850
Update .travis.yml
PhrozenByte Oct 28, 2015
38081b3
Sync docs with website
PhrozenByte Oct 28, 2015
638638f
Add UPGRADE section to docs
PhrozenByte Oct 28, 2015
f1fc4c9
Revert commit a068850
PhrozenByte Oct 29, 2015
54ce5b9
Various small improvements
PhrozenByte Oct 29, 2015
d29e2c1
Add CONTRIBUTING.md
PhrozenByte Oct 29, 2015
7a69fdf
Update CONTRIBUTING.md
PhrozenByte Oct 29, 2015
e6681ea
Improve class docs
PhrozenByte Oct 29, 2015
afb55b9
Improve class docs
PhrozenByte Oct 29, 2015
9a70241
Remove `return $config` in `config/config.php`
PhrozenByte Oct 30, 2015
8da62f4
PicoDeprecated: Making $config globally accessible again
PhrozenByte Oct 31, 2015
85d7c51
Update CONTRIBUTING.md
PhrozenByte Nov 2, 2015
2597e0d
Move upgrade instructions from inline docs to README.md in a more gen…
PhrozenByte Nov 2, 2015
ebe007b
Guess content directory
PhrozenByte Nov 2, 2015
a1331e7
Update inline docs to reflect ebe007b
PhrozenByte Nov 2, 2015
8db3bc5
Update changelog.txt to reflect ebe007b
PhrozenByte Nov 2, 2015
92adb27
Update README.md
PhrozenByte Nov 2, 2015
0e0eb56
Update CONTRIBUTING.md
PhrozenByte Nov 2, 2015
641a5d1
Merge branch 'pico1.0' of github.com:PhrozenByte/Pico into pico1.0
PhrozenByte Nov 2, 2015
d65eb55
Update README.md
PhrozenByte Nov 2, 2015
2ab3611
Update content-sample/index.md
PhrozenByte Nov 2, 2015
ffc5936
README.md: Add Getting Help section
PhrozenByte Nov 3, 2015
365333c
Update content-sample/index.md
PhrozenByte Nov 3, 2015
48264fc
Move license.txt and changelog.txt
PhrozenByte Nov 3, 2015
8164038
Use Markdown for CHANGELOG.md
PhrozenByte Nov 3, 2015
82e0ca5
Small changes
PhrozenByte Nov 3, 2015
90128f4
Fix possible foreach on null errors
PhrozenByte Nov 3, 2015
e3a6116
Sync documentation
PhrozenByte Nov 4, 2015
ccac8dd
Force trailing slash of $config['base_url'] and force existance of $c…
PhrozenByte Nov 4, 2015
2a43b21
Enable PicoDeprecated if no plugins are loaded
PhrozenByte Nov 4, 2015
af8de56
Fix typos
PhrozenByte Nov 4, 2015
19f708e
Sync documentation
PhrozenByte Nov 4, 2015
b5d54d0
Update .travis.yml: Name release archives "pico-release-$TRAVIS_TAG.t…
PhrozenByte Nov 5, 2015
cd7cd37
Add content filter to get the parsed contents of a page (lazy loading)
PhrozenByte Nov 6, 2015
e3e0300
Fix typo
PhrozenByte Nov 6, 2015
82cbe37
fix typos
theshka Nov 6, 2015
cd1dc07
Sync docs
PhrozenByte Nov 6, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
SCANDIR_SORT_* constants are available since PHP 5.4
Thanks @Lomanic
  • Loading branch information
PhrozenByte committed Oct 4, 2015
commit 3a4721a20c56ac831c2847355d343eedfc5c8552
36 changes: 30 additions & 6 deletions lib/Pico.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,30 @@
*/
class Pico
{
/**
* Sort files in alphabetical ascending order
*
* @see Pico::getFiles()
* @var int
*/
const SORT_ASC = 0;

/**
* Sort files in alphabetical descending order
*
* @see Pico::getFiles()
* @var int
*/
const SORT_DESC = 1;

/**
* Don't sort files
*
* @see Pico::getFiles()
* @var int
*/
const SORT_NONE = 2;

/**
* Root directory of this Pico instance
*
Expand Down Expand Up @@ -708,7 +732,7 @@ public function getFileContent()
protected function readPages()
{
$this->pages = array();
$files = $this->getFiles($this->getConfig('content_dir'), $this->getConfig('content_ext'), SCANDIR_SORT_NONE);
$files = $this->getFiles($this->getConfig('content_dir'), $this->getConfig('content_ext'), Pico::SORT_NONE);
foreach ($files as $i => $file) {
// skip 404 page
if (basename($file) == '404' . $this->getConfig('content_ext')) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like in Pico 0.9, we exclude all 404.md files in any folder (e.g. sub/404.md). Pico 0.9 however always uses the "root" 404.md. What do you think about supporting directory-specific 404 files?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I don't see a particularly compelling use case that makes up for the added complexity that would bring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could want to use a different 404.md for his blog, e.g. showing a tag cloud, what wouldn't make much sense for non-blog-pages. Apart from the use case, should we then still exclude all 404.md files or just the "root" 404.md?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the added 10 LoC is it worth to resolve this undocumented and not expected behavior...

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the unexpected behaviour you are referribg to?

Le dimanche 4 octobre 2015, Daniel Rudolf notifications@github.com a
écrit :

In lib/Pico.php
#252 (comment):

  • {
  •    return $this->content;
    
  • }
  • /**
  • \* Reads the data of all pages known to Pico
    
  • *
    
  • \* @return void
    
  • */
    
  • protected function readPages()
  • {
  •    $pages = array();
    
  •    $files = $this->getFiles($this->getConfig('content_dir'), $this->getConfig('content_ext'));
    
  •    foreach ($files as $i => $file) {
    
  •        // skip 404 page
    
  •        if (basename($file) == '404' . $this->getConfig('content_ext')) {
    

I think the added 10 LoC is it worth to resolve this undocumented and not
expected behavior...


Reply to this email directly or view it on GitHub
https://github.com/picocms/Pico/pull/252/files#r41097723.

Brice Boucard

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the commented line and 77f9390 😄

Pico 0.9 excluded all 404.md files in any directory from the pages list, even they weren't functional. This never was documented and is unexpected behavior - you either expect that only the global 404.md file is removed or that Pico supports per-directory 404.md files. The first solution would break BC, so I decided that the additional 10 LoC are it worth to resolve this problem.

Expand Down Expand Up @@ -990,12 +1014,12 @@ public function getPageUrl($page)
* @param string $fileExtension return files with the given file extension
* only (optional)
* @param int $order specify whether and how files should be
* sorted; use SCANDIR_SORT_ASCENDING for a alphabetical ascending
* order (default), SCANDIR_SORT_DESCENDING for a descending order or
* SCANDIR_SORT_NONE to leave the result unsorted
* sorted; use Pico::SORT_ASC for a alphabetical ascending order (this
* is the default behaviour), Pico::SORT_DESC for a descending order
* or Pico::SORT_NONE to leave the result unsorted
* @return array list of found files
*/
protected function getFiles($directory, $fileExtension = '', $order = SCANDIR_SORT_ASCENDING)
protected function getFiles($directory, $fileExtension = '', $order = self::SORT_ASC)
{
$directory = rtrim($directory, '/');
$result = array();
Expand All @@ -1013,7 +1037,7 @@ protected function getFiles($directory, $fileExtension = '', $order = SCANDIR_SO

if (is_dir($directory . '/' . $file)) {
// get files recursively
$result = array_merge($result, $this->getFiles($directory . '/' . $file, $fileExtension));
$result = array_merge($result, $this->getFiles($directory . '/' . $file, $fileExtension, $order));
} elseif (empty($fileExtension) || (substr($file, -$fileExtensionLength) === $fileExtension)) {
$result[] = $directory . '/' . $file;
}
Expand Down