aboutsummaryrefslogtreecommitdiff
path: root/page.c
Commit message (Collapse)AuthorAgeFilesLines
* page.c: Align results to centerv0.4.0Xavier Del Campo Romero2025-10-101-5/+5
|
* page.c: Ensure trailing '/' on dir download URLsXavier Del Campo Romero2025-10-101-1/+1
| | | | | | | Otherwise, it is not ensured web browsers would translate a relative directory such as "dir/.." to a URL with a trailing '/'. Therefore, a POST request to "/user?download=1" would fail because slcl only considers "/user/" (note the trailing '/') as valid.
* page.c: Center directory/file and page countXavier Del Campo Romero2025-10-091-11/+12
|
* page.c: Switch preview and downloadXavier Del Campo Romero2025-10-081-17/+35
| | | | | | | | | | | | | | | So far, clicking on a directory name previewed it, whereas clicking on a file name would download it, and file previews were on a separate column. This behaviour was found to be confusing, so it has been simplified. Now, clicking on a file or directory name would preview it. On the other hand, the "Preview" column has been replaced with a "Download" column, so that both files and directories can be downloaded. Thanks to Avron for the suggestion. [1] [1]: https://codeberg.org/xavidcr/slcl/issues/2
* page.c: Move remove checkbox to the rightXavier Del Campo Romero2025-10-081-1/+1
| | | | | | It feels more intuitive to keep the thumbnail and file name as first columns. It is assumed removing files and/or directories is not the main interaction from users.
* page.c: Remove unused variableXavier Del Campo Romero2025-10-081-1/+1
|
* Implement directory download as ZIPXavier Del Campo Romero2025-10-081-1/+25
| | | | | | | | | | | | | | | | | | | | | | | | Thanks to the fdzipstream library [1] and zlib [2], it is possible to generate ZIP files on-the-fly, therefore requiring no extra disk space usage and only a small amount of memory. Unfortunately, as of the time of this writing fdzipstream is not packaged by any distributions yet [3], so it had to be imported as a git submodule as a workaround. While libarchive [4] could be an interesting alternative, writing ZIP files is only supported by very recent versions (>= 3.8.0), which are still not packaged by many distributions [5], either. Moreover, libarchive is a package with several dependencies other than zlib and is significantly larger compared to fdzipstreams, so fdzipstreams was ultimately considered a better fit for this purpose. [1]: https://github.com/CTrabant/fdzipstream.git [2]: http://zlib.net/ [3]: https://repology.org/projects/?search=fdzipstream [4]: https://www.libarchive.org/ [5]: https://repology.org/project/libarchive/versions
* page.c: Report logged user name on directory previewXavier Del Campo Romero2025-10-061-14/+39
| | | | | | Thanks to Avron for the suggestion. [1] [1]: https://codeberg.org/xavidcr/slcl/issues/2
* page.c: Add table head for directory previewXavier Del Campo Romero2025-10-061-2/+55
| | | | | | Thanks to Avron for the suggestion. [1] [1]: https://codeberg.org/xavidcr/slcl/issues/2
* Fix wrong function names on failureXavier Del Campo Romero2025-10-021-1/+1
|
* Display thumbnails, if availableXavier Del Campo Romero2025-09-241-11/+136
|
* main.c: Forbid sharing non-existing filesXavier Del Campo Romero2025-01-231-1/+1
| | | | | | | | | | | So far, slcl would allow to share literally any directory or file, even if they did not exist, as long as valid credentials were given. Now, directories cannot be shared, since this is already restricted by the web interface. This is now considered an invalid request. On the other hand, attempting to share non-existing files shall now return a 404 Not Found response to the user.
* Implement directory pagingXavier Del Campo Romero2024-08-281-24/+296
| | | | | This allows directories with many files and directories inside them to be split into pages, in order to limit resource usage.
* page.c: Do not get filename on previewsXavier Del Campo Romero2024-03-011-9/+9
| | | | | | This change should provide the same behaviour, but would avoid unnecessary calls to dynstr_append and basename(3) when a preview is to be served.
* page.c: Use open(2) fdopen(3) and fstat(2)v0.2.1-rc1Xavier Del Campo Romero2024-02-191-25/+79
| | | | | Now, the same file descriptor can be reused for all of the operations above, instead of calling stat(2) and fopen(3) separately.
* page.c: URL-encode hrefXavier Del Campo Romero2024-02-191-3/+25
| | | | | Otherwise, files with special characters, such as '%', could not be downloaded or previewed.
* Implement HEAD supportXavier Del Campo Romero2023-10-141-0/+33
|
* List number of files and directoriesv0.1.0-rc3Xavier Del Campo Romero2023-10-111-23/+82
| | | | | Sometimes, users want to know how many files and/or directories reside on a directory. Now, slcl prints such information below the logout form.
* page.c: Force whitespace renderingXavier Del Campo Romero2023-10-111-1/+1
|
* Apply slweb renaming to libwebXavier Del Campo Romero2023-10-111-2/+2
|
* page.c: Update project URLXavier Del Campo Romero2023-09-091-1/+1
|
* Do some minor rebrandingXavier Del Campo Romero2023-08-011-2/+3
| | | | | | Despite designed around portability and minimalism, I feel slcl no longer aligns with the philosophical views from the suckless project. Therefore, I think it was appropriate to unlink its branding from it.
* Adapt to slweb's include pathsXavier Del Campo Romero2023-07-211-2/+2
| | | | | slweb puts its header files into its own directory in order to avoid potential name clashing.
* Limit amount of search resultsXavier Del Campo Romero2023-07-111-2/+72
| | | | | | | | | | When a user enters a search term that is too generic, slcl would generate a long list of search results, where this generation could have a big impact on the server performance and its available resources. Therefore, it is reasonable to limit the number of search results to an arbitrary limit, so that users are forced to enter a more specific search term in order to achieve more relevant results.
* Allow admins to define their own stylesheetXavier Del Campo Romero2023-07-111-54/+26
| | | | | | | | | | | | slcl used to provide a hardcoded stylesheet. However, it would be desirable for some admins to provide a custom stylesheet without having to rebuild the application. Now, slcl creates a default stylesheet, namely style.css, into the target directory, that can be later modified by admins. While this might contradict the suckless philosophy a bit, hopefully some admins might find this new feature useful.
* page.c: Allow add_element to hide checkboxesXavier Del Campo Romero2023-07-091-4/+4
| | | | | Since removing files or directories is currently not an option in searches, it is better to leave checkboxes out to avoid confusion.
* page.c: Remove back button from searchesXavier Del Campo Romero2023-07-091-43/+0
| | | | | | | | - The back button would not return to the previous directory, but to the user root directory. - While this could have been solved easily (e.g.: by inserting the referrer directory into the form), it would have implied extra and unneeded complexity.
* Implement file/directory removalXavier Del Campo Romero2023-07-081-1/+359
| | | | | | | | | | | | | | | The following workflow has been implemented: - A new checkbox for each object inside a directory is shown. - When one or more objects are selected, the user submits a request through a HTML5 form. - Then, slcl will ask the user for confirmation, listing the selected objects, while reminding the user about the effects. - The user confirms the selection. - slcl removes the selected objects. All objects from non-empty directories are removed, too. - Finally, slcl redirects the user to the directory the request was made from.
* page.c: Return HTTP_STATUS_OK on successful page_searchXavier Del Campo Romero2023-07-081-1/+1
| | | | | This was probably a copy-paste issue when implementing page_search based on page_quota_exceeded.
* Implement searchXavier Del Campo Romero2023-06-061-1/+239
| | | | | | This new feature adds a HTML form on each directory listing that allows to search files recursively, starting from the current user directory. Wildcard patterns are also allowed.
* page.c: Apply minor fixes and improvements to stylesheetXavier Del Campo Romero2023-06-061-3/+3
| | | | | | - Rules applying to body already apply to input. - input already had a "margin: auto" rule. - Missing whitespace on "margin:auto" rule.
* page.c: Call page_not_found on ENOTDIRXavier Del Campo Romero2023-06-061-1/+1
| | | | | ENOTDIR is another non-fatal errno value that can be returned by stat(2).
* page.c: Display login forms as gridXavier Del Campo Romero2023-06-021-1/+5
| | | | | | While commit 1ffba8f5 fixed a wrong display of the mkdir, upload and logout forms, it did not take login forms into consideration, which must displayed as grid.
* page.c: Add padding to mkdir, logout, and upload formsXavier Del Campo Romero2023-06-021-0/+24
|
* page.c: Do not display forms as gridXavier Del Campo Romero2023-06-021-4/+0
| | | | | Otherwise, each element from the form would be stacked on top of another, which is confusing to users.
* page.c: Apply max-width to tableXavier Del Campo Romero2023-05-301-0/+4
| | | | This will help users to read tables with long file names.
* page.c: Apply lightgray background to even cellsXavier Del Campo Romero2023-05-301-0/+4
| | | | This will help users to navigate through large tables.
* Implement file previewsXavier Del Campo Romero2023-04-231-18/+83
| | | | | | | | | | | | | When using HTTP "Content-Disposition: attachment;", users are forced to download files in order to use them, whereas others might prefer to open them in the browser. Therefore, now that URL parameters are supported by http.h, previews can be forced by adding "preview=1" or "preview=true" (case-insensitive) as a URL parameters. Any other parameters are ignored by slcl. For users, a "Preview" link has been added next to the "Share" button for each file.
* Improve CSS and apply to list_dirXavier Del Campo Romero2023-04-171-10/+54
|
* Define _POSIX_C_SOURCEXavier Del Campo Romero2023-03-241-0/+2
| | | | | This allows using the default compiler defined by make(1) (i.e., c99(1)), thus improving POSIX compatibility.
* Send response on quota exceededXavier Del Campo Romero2023-03-201-0/+90
| | | | | | | | | | | | | | | | | So far, slcl would just close the connection with a client when the Content-Length of an incoming request exceeded the user quota, without any meaningful information given back to the user. Now, slcl responds with a HTML file with meaningful information about the error. Limitations: - While this commits has been successfully tested on ungoogled-chromium, LibreWolf (and I assume Firefox and any other derivates too) does not seem to receive the response from the server. - However, this issue only occurred during local testing, but not on remote instances.
* page.c: Set Content-Disposition when serving filesXavier Del Campo Romero2023-03-161-5/+96
| | | | | | | | | | | | | | So far, slcl used the default browser behaviour (i.e., Content-Disposition: inline), which means files were typically shown on the web browser itself. However, this caused two issues: - Users would have to right-click -> "Save Link As..." to download a file, which might be inconvenient for some users. - The original file name would not be retrieved for publicly shared files. Now, file download is always requested to the browser, and the original file path is retrieved via readlink(2).
* page.c: Fix wrong error messageXavier Del Campo Romero2023-03-091-1/+1
|
* Implement public file sharingXavier Del Campo Romero2023-03-091-1/+185
| | | | | | | | | | | | | An HTML form is now added next to each regular file, that generates a POST request. Then, slcl replies with a HTML document with a link to the public resource (which are implemented as symlinks). Limitations: - For now, only regular files can be shared i.e., sharing directories is not possible. While feasible, it still requires a larger refactor to list_dir and resource_layout, so that read-only access to the directory is provided to anonymous users.
* page.c: Provide meaningful description on HTTP 404Xavier Del Campo Romero2023-03-091-8/+28
|
* page.c: Implement function for common <head> nodesXavier Del Campo Romero2023-03-091-34/+55
| | | | This will be used by future commits.
* page.c: Set common <head> parametersXavier Del Campo Romero2023-03-081-3/+7
|
* page.c: Show units for user quotaXavier Del Campo Romero2023-03-081-22/+52
|
* page.c: Sort elements alphabeticallyXavier Del Campo Romero2023-03-081-26/+64
|
* Implement user quotaXavier Del Campo Romero2023-03-061-3/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature allows admins to set a specific quota for each user, in MiB. This feature is particularly useful for shared instances, where unlimited user storage might be unfeasible or even dangerous for the server. Also, a nice HTML5 <progress> element has been added to the site that shows how much of the quota has been consumed. If no quota is set, slcl falls back to the default behaviour i.e., assume unlimited storage. Limitations: - While HTTP does specify a Content-Length, which determines the length of the whole request, it does not specify how many files are involved or their individual sizes. - Because of this, if multiple files are uploaded simultaneously, the whole request would be dropped if user quota is exceeded, even if not all files exceeded it. - Also, Content-Length adds the length of some HTTP boilerplate (e.g.: boundaries), but slcl must rely on this before accepting the whole request. In other words, this means some requests might be rejected by slcl because of the extra bytes caused by such boilerplate. - When the quota is exceeded, slcl must close the connection so that the rest of the transfer is cancelled. Unfortunately, this means no HTML can be sent back to the customer to inform about the situation.