picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.83k stars 617 forks source link

Get content from external files? #417

Closed Geri-Borbas closed 6 years ago

Geri-Borbas commented 6 years ago

Hi, I love pico.

Sorry for not browsing through the entire docs / issues, I'm in a hurry today (where pico help a lot): Can I include the contents from external source?

I'd like to maintain a GitHub repository with all *.md files, and render the site from there. Any examples perhaps?

PhrozenByte commented 6 years ago

Rendering a site directly from an external source is probably not a good idea - performance reasons, you know 😉 However, this doesn't mean that you can't use a Git repository (e.g. on GitHub) to manage your website.

First of all I recommend using Pico 2.0 (don't worry about Pico 2.0 being in beta, the only reason this isn't the final release is that we're still working on the docs - help is highly appreciated btw), it made things like this way easier. Simply fork picocms/pico-composer, clone your repo locally and run composer install. Add your .md filtes to the content/ directory as well as all plugins and themes you want to use. Then commit & push your changes. After you've tested your website locally, open a shell on your webserver, navigate to the desired install directory and clone your GitHub repo. Run composer install to actually install Pico - and you're ready to go 😃

If you want to update your website simply apply your changes (either locally (don't forget to commit & push), or using GitHub's online editor) and then do a git pull on your webserver to apply the changes to your productive website. You can even automate this process using a cronjob, or a Git hook, or a GitHub webhook.

Geri-Borbas commented 6 years ago

Thanks for getting back. I will do something similar, probably add the content/, plugins/ and themes/ folder to a submodule to my fork of pico.

I was hoping for a "deployless" workflow, but I'm not complaining at all. Pico already saved my day, thanks for that.

Geri-Borbas commented 6 years ago

Well, pico 2 just said that:

Cannot find 'vendor/autoload.php'. Run `composer install`.

On install, it says:

$ curl -sS https://getcomposer.org/installer | php
Downloading...

Composer (version 1.6.3) successfully installed to: <REDACTED>/composer.phar
Use it: php composer.phar

Some settings on your machine may cause stability issues with Composer.
If you encounter issues, try to change the following:

The OpenSSL library (0.9.8r) used by PHP does not support TLSv1.2 or TLSv1.1.
If possible you should upgrade OpenSSL to version 1.0.1 or above.

$ php composer.phar install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package picocms/pico ^2.0 is satisfiable by picocms/pico[2.0.x-dev, v2.0.0-beta.1, v2.0.0-beta.2] but these conflict with your requirements or minimum-stability.
  Problem 2
    - The requested package picocms/pico-theme ^2.0 is satisfiable by picocms/pico-theme[2.0.x-dev, v2.0.0-beta.1, v2.0.0-beta.2] but these conflict with your requirements or minimum-stability.
  Problem 3
    - The requested package picocms/pico-deprecated ^2.0 is satisfiable by picocms/pico-deprecated[2.0.x-dev, v2.0.0-beta.1, v2.0.0-beta.2] but these conflict with your requirements or minimum-stability.

eppz-MacBook-Pro:tangram.eppz.eu eppz$ 

Then the site is still:

Cannot find 'vendor/autoload.php'. Run `composer install`.
Geri-Borbas commented 6 years ago

Anyway, I copied over manually the latest beta 2 release, now it works fine. I cannot update, however. Same error messages.

z$ php composer.phar update
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for picocms/pico ^2.0 -> satisfiable by picocms/pico[v2.0.0-beta.2].
    - Removal request for picocms/pico == 2.0.0.0-beta2
  Problem 2
    - Installation request for picocms/pico-theme ^2.0 -> satisfiable by picocms/pico-theme[v2.0.0-beta.2].
    - Removal request for picocms/pico-theme == 2.0.0.0-beta2
  Problem 3
    - Installation request for picocms/pico-deprecated ^2.0 -> satisfiable by picocms/pico-deprecated[v2.0.0-beta.2].
    - Removal request for picocms/pico-deprecated == 2.0.0.0-beta2
PhrozenByte commented 6 years ago

This is a temporary error due to Pico 2.0 officially still being in beta. You can safely lower the minimum stability for Pico's components (Pico itself, the official PicoDeprecated plugin and Pico's official default theme) by running the following commands (this updates the composer.json):

$ composer require --no-update picocms/Pico:^2.0@beta
$ composer require --no-update picocms/pico-deprecated:^2.0@beta
$ composer require --no-update picocms/pico-theme:^2.0@beta
$ composer install

However, just copying over the files from Pico's pre-built package has virtually the same effect 😄

Geri-Borbas commented 6 years ago

Thanks, I just did that. Yay, now I can both update and install. I sure wanted to maintain uplink, I could already update symfony/yaml compared to 2.0.0-beta.2 release.

Geri-Borbas commented 6 years ago

Just a quick question, you are such responsive. 😄 Can I create redirect pattern like: my.site.com/presskit, instead my.site.com/?presskit.

I have some links already shared, I want to preserve them.

PhrozenByte commented 6 years ago

Sure. Simply refer to the "URL rewriting" section in Pico's sample contents or the "URL rewriting" section in the user docs

Geri-Borbas commented 6 years ago

Huge thannnnkkksss for your assistance!

Geri-Borbas commented 6 years ago

Hi, have rewrite enabled, however, it does not resolve the URLs.

I have this in my httpd.conf:

LoadModule rewrite_module modules/mod_rewrite.so

And this in my config.yml

rewrite_url: true

But it still only works with ?. Which prevents me from using pico actually. Can I work this around with some direct .htaccess magic perhaps?

PhrozenByte commented 6 years ago

Did you restart your Apache webserver? Is Pico's .htaccess file present in the installation directory? Make sure that AllowOverride for the installation directory (or one of its parent directories) is set to at least AllowOverride FileInfo or AllowOverride All.

Geri-Borbas commented 6 years ago

Thanks! Can I put this into .htaccess somehow?

On the production environment, I have no control over server configuration (luckily mod_rewrite is turned on there as well).

PhrozenByte commented 6 years ago

No, this is necessary to use .htaccess

Geri-Borbas commented 6 years ago

Thanks, now I just actually want it working. It just shows response code 500 now.

I have worked the hell around it, just exported static pages, as this already consumed my entire afternoon. I could have installed 500 WordPress within this timeframe.

This redirection issue - and the lack of documentation on it -, just killed the purpose of simplicity. I still want to use pico, but first I need to see it working in production (not only on a local MAMP server).

PhrozenByte commented 6 years ago

There is no "lack of documentation", this issue is not related to Pico, but to a broken webserver config. Configuring your webserver is out of Pico's (and any other CMS', including WordPress') influence. Check your webserver error log. The error might be related to your webserver config disallowing the use of the Options directive. However, I unfortunately don't have a crystal ball, I'm just guessing what might be wrong with your webserver config. Try removing the Options directive from Pico's .htaccess file. Also remove all .htaccess files in parent folders, they indeed might break your webserver. If you rather want to use WordPress, use it. This is just a hobby, we don't force anyone to use Pico.

Geri-Borbas commented 6 years ago

Thanks for your answer, and the suggestions. I totally understand, I just had to ventilate some frustration over. 😃

I'll fiddle with this once I'll have time for that. I do not want to use WordPress, I really want something more lightweight.

Geri-Borbas commented 6 years ago

I tried both suggestions, also tried to hardcode base_url, no luck. Can I turn on error logging somehow?

Geri-Borbas commented 6 years ago

I added:

error_reporting(E_ALL);
ini_set('display_errors', '1');

It says:

Warning: require_once(<PATH>/vendor/autoload.php): failed to open stream: No such file or directory in <PATH>/index.php on line 29

Fatal error: require_once(): Failed opening required '<PATH>/vendor/autoload.php' (include_path='.:/usr/share/php:/usr/share/pear') in <PATH>/index.php on line 29

But autoload.php is there. Furthermore, it works when running local. Could this be something due to the "manual" installation I did?

Geri-Borbas commented 6 years ago

Wow, I just found /vendor is ignored in .gitignore. Hopefully, adding will solve the issue. Seemingly it has nothing to do with .htaccess.

PhrozenByte commented 6 years ago

The vendor/ dir is ignored on purpose, it's composer's job to create it. Refer to what I wrote above:

After you've tested your website locally, open a shell on your webserver, navigate to the desired install directory and clone your GitHub repo. Run composer install to actually install Pico - and you're ready to go 😃

Make sure the file permissions are correct and your webserver and/or PHP user can access the files. If the webserver/PHP user can't access the vendor/ dir, it also won't be able to notice that vendor/autoload.php exists.

As said previously you can also manually upload the vendor/ dir instead of using composer install.

Geri-Borbas commented 6 years ago

I can't run scripts there, only upload files. Anyway, I removed .gitignore files actually all around.

Geri-Borbas commented 6 years ago

Yay, now it works. I set rewrite_url: true per documentation (!), now that works as well. 😄

Geri-Borbas commented 6 years ago

I'd appreciate if you could take a look at Unable to add filter "navigation" as extensions have already been initialized please. Those folks seem much less responsive.