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

Cleaner file structure #913

Open
jtojnar opened this issue Apr 9, 2017 · 3 comments
Open

Cleaner file structure #913

jtojnar opened this issue Apr 9, 2017 · 3 comments
Milestone

Comments

@jtojnar
Copy link
Member

jtojnar commented Apr 9, 2017

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

  • 📂 data (writeable)
    • 📁 cache
    • 📁 logs
    • 📁 sqlite
    • 📄 config.ini
  • 📁 plugins
  • 📂 public (accessible)
    • 📂 assets
      • 📁 css
      • 📁 fonts
      • 📁 images
      • 📁 js
      • 📄 favicon.svg
    • 📂 gen (writeable)
      • 📁 favicons
      • 📁 thumbnails
      • 📄 all.css
      • 📄 all.js
  • 📂 src
    • 📁 controllers
    • 📁 daos
    • 📁 helpers
    • 📁 lang
    • 📁 spouts
    • 📁 templates
    • 📄 common.php
  • 📁 tests
  • 📁 utils
  • 📁 vendor
  • 📄 .htaccess
  • 📄 index.php
  • 📄 README.md
  • 📄 run.php

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

  • Automated installer should be able to write config.ini, data is thus a good location for it.
  • I would like to split selfoss-client off of selfoss. That would mean selfoss would drop the templates and assets directories, only keeping the API, favicons and thumbnails.
  • Maybe selfoss could be compiled to PHAR to reduce the number of files (faster upload to FTP). At least the public and data directories would need to be kept outside.
  • If we created a plugin manager as a part of selfoss, it would need to be able to write to plugins directory.
  • There should be a place for tests, it should be easily separable from the source code so it could be excluded in the build.

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
Copy link
Collaborator

niol commented Apr 10, 2017

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
Copy link
Member Author

jtojnar commented Apr 10, 2017

  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 jtojnar added this to the 2.19 milestone Jan 27, 2019
@jtojnar jtojnar modified the milestones: 2.19, 3.0 Apr 4, 2019
@jtojnar jtojnar mentioned this issue Sep 25, 2019
3 tasks
@jtojnar
Copy link
Member Author

jtojnar commented Sep 26, 2019

With #1137, we will be one step closer:

  • 📂 assets
    • 📁 css
    • 📁 images
    • 📁 js
    • 📁 locale
  • 📂 data (writeable)
    • 📁 cache
    • 📁 logs
    • 📁 sqlite
    • 📁 favicons (still here)
    • 📁 thumbnails (still here)
  • 📂 public (accessible, generated statically)
    • 📄 all.css
    • 📄 all.js
  • 📂 src
    • 📁 controllers
    • 📁 daos
    • 📁 helpers
    • 📁 spouts
    • 📁 templates
    • 📄 common.php
  • 📁 utils
  • 📁 vendor
  • 📄 .htaccess
  • 📄 config.ini (still here)
  • 📄 index.php
  • 📄 README.md
  • 📄 run.php

@squatica squatica mentioned this issue Feb 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants