fossar / selfoss

multipurpose rss reader, live stream, mashup, aggregation web application
https://selfoss.aditu.de
GNU General Public License v3.0
2.35k stars 344 forks source link

Cleaner file structure #913

Open jtojnar opened 7 years ago

jtojnar commented 7 years ago

The existing structure is unnecessarily complicated:

  1. The different source files are intermingled with the rest, all the source directories have to be set for each tool manually.
  2. There are some directories that need to be accessible from the HTTP server but they are again located in different places (public and data).
  3. There are directories that need to be writeable and not accessible.

Goals

  1. Related files and directories should be grouped together.
  2. Files that should not be accessible should not be grouped with public ones.
  3. Configuring web server should be simple – there should not be any complicated rewrite rules so that selfoss could be installed on non-traditional servers without much work.
  4. Installation should be simple (chmoding as few directories as possible).

Proposed directory structure

The public directory can either be set as document root of virtual host or there can be a simple .htaccess in the parent directory.

Further goals to consider

Simpler .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    # RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule !\.(pdf|js|ico|gif|jpg|png|css|rar|zip|tar\.gz)$ index.php [L]
</IfModule>
niol commented 7 years ago

Nice.

  1. We should plan for a test directory or make the planned structure not incompatible with the presence of such directory.
  2. Some people run selfoss in restricted hosting and do not have access to setting the document root: the document root is the upload root. Therefore, I think index.php in the projet root cannot be avoided, although for people selfoss on less restricted environments, putting the libs out of the document root is desirable. We should support both.
jtojnar commented 7 years ago
  1. I would place the tests directory to the root. Other possible location is src/tests, which could make linting them easier but they would have to be explicitly excluded from the build. For that reason, placing tests next to the file/class they test is out of the game.
  2. Actually, I am one of those people.

    1. The problem could be fixed by placing an additional .htaccess in the project root, that would rewrite to the document root. In pseudo-code:

      if $url begins with 'public/'
         remove prefix 'public/'
      rewrite (.*) to public/$1

      It might be slightly confusing what the document root should be, but that could be rectified in the docs.

    2. Keeping the index.php in the project root would mean one fewer .htaccess but there would need to be access control at least for the data directory.

jtojnar commented 4 years ago

With #1137, we will be one step closer: