Code Monkey home page Code Monkey logo

homebooru's Introduction

Homebooru

Artwork by Navi


A self-hosted Booru written in Python (Django) for storing and sorting large media collections.

Installation

Included with the repository is a Docker compose configuration file, this should set everything up for you automatically. You can run the following command to start the server:

$ docker-compose up --build

Configuration

By default, since the PostgreSQL database should be locked off from the rest of the network, the server will have a default username and password of homebooru and H0meboOru!420. You can change these by editing the .env file in the root directory.

Note: If you wish to access the server from other computers on your network, you will need to change the validate.conf file in the .nginx directory. This is covered in the Specifying origins section.

Specifying origins

Homebooru's nginx configuration is configured, by default, to only accept requests from localhost and 127.0.0.1, this is to prevent unauthorised access from foreign hosts.

Don't worry, you can change this by editing the validate.conf file in the .nginx directory (.nginx/sec/validate.conf).

Firstly, let me explain briefly what an origin is; an origin is the address that you type into the address bar of your browser to access the server, so (for me) I would enter https://10.0.2.43 and the origin would be 10.0.2.43. To allow this origin, I would add the following to the validate.conf file:

# Check that the origin is acceptable and expected.
if ($host !~* ^(localhost|127.0.0.1|10.0.2.43)$) {
    ...

Remember, if you are wishing to use a domain name (for example, example.com) you can add this here too:

if ($host !~* ^(localhost|127.0.0.1|10.0.2.43|example.com)$) {
    ...

Of course, if you just want your domain to be the origin you could just remove the localhost|127.0.0.1| ... etc. and just add yourdomain.com in its place.

Contributions

If you have any suggestions for improvements, please open an issue on the GitHub repository. If you have a bit of knowledge with Python and Django, feel free to fork the repository and submit a pull request for new features. Before contributing to the project, I would recommend reading some of the Miscellaneous Project Information to understand why certain things are implemented in certain ways and maybe what ethics you should work with when contributing (such as the low JavaScript dependence).

Debug Environment

To make it easier to debug, I have created a docker-compose.yml file alongside a .env file, in the .debug directory.

This file is similar to the main docker-compose.yml file, but with the following differences:

  • Persistent volumes are not used (i.e. no volumes section)
  • The nginx container is not used.
  • By default, the container will only run unit tests - (this is mainly to encourage contributors to write tests for their own code).
  • Direct pass-through to the Django debug server is enabled. (by default, the port is set to 8000)

That all sounds great, but how do I use this environment? This is very straight forward - just run the following command:

# Move to the .debug directory
$ cd .debug

# Run the debug environment
$ docker-compose up --build

And to stop the environment, run the following command (while in the .debug directory, of course):

$ docker-compose down

Enabling the Debug Web Server

As you may have read earlier, the debug environment is setup to run unit tests and close the server after the tests are complete, however sometimes you might want a more live/real-time server. To enable this, simply set UNIT_TEST to False in the debug .env file like so:

UNIT_TEST=False

homebooru's People

Contributors

dependabot[bot] avatar gingerchicken avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

homebooru's Issues

Remove pagination from backend functions

Within both the search posts and search tags functions, there are paginator objects being made, I feel that this is adding an unnecessary use case to these objects, the paginator itself should be responsible for handling pagination!

  • Remove paginator functionality from mentioned functions
  • Add paginator functionality to relevant pages using Paginator object instead

Add dark theme

  • Add CSS to make the site dark theme
  • Add a cookie to let the user choose their theme
  • If the user has the cookie, in head will automatically include the dark theme
  • There should be a setting to auto-enable dark theme

Add frontend coverage report

The front end code (e.g. the Jinja/HTML) is not covered in the coverage report - this is just as important as the back end code so it should be in the report

Justify non-RESTful endpoints

Document what the upload and edit endpoints are and their purpose throughout the project:

  • Explain why these endpoints are not fully RESTful (talking about privacy and no-JS)
  • Discuss future plans to implement a RESTful API

Add login page

  • This should allow Django users log in to the site
  • The login should be maintained via a cookie
  • A session should be started

Add unit test env var

This should trigger unit tests to be performed before launching the server - this way we can then setup CI!

Add post editting

Allow authorised users to modify the following

  • Tags
  • Rating
  • Title
  • Origin

It must only be able to be done when the user has the perm booru.change_post

Suppress bad request warnings during tests

Whenever you run tests, the console is flooded with WARNING:django.request:Bad Request: /upload - these are mostly for expected 400 errors, these should be suppressed.

Upload user output

After uploading the image:

  • it should redirect the user to the post.

In addition,

  • if there's an error, the error should be shown on the screen.

Improve original viewing

  • Always view original should display the original all the time
  • Do not show this message should hide the message forever
  • These should be usable without JavaScript being enabled
  • The here button should resize the image using JavaScript - if and only if, JS is enabled.

imagen

Use Django forms

For easier validation etc. maybe move to using Django forms for:

  • The upload page
  • Tag editting form

Minify css

The bootstrap stuff should really be removed and replaced by a library but whatever, for now just minify it

Reject tags that start with params

So things such as md5: ... and rating: ... tags should be denied when tags are created

  • Shows an error on the upload page upon rejection

Rejects:

  • md5:
  • rating:
  • width:
  • height:
  • title:

Use reverse for URLs

This should be applied to the frontend URLs as currently the URLs are hardcoded and hence non-dynamic.

View post functionality

Add more functionality without JavaScript to the view page:

  • Add search tag button
  • Remove search tag button
  • Fix clicking a tag to search it

Searching with specified start

When searching for thing such as a*, it returns all items that include tags with the letter a in it, however, this should only return all that start with a!

Make tag edit open in new tab

When you click on a tag in the search, it should probably open in a new tab so that the search results can be kept.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.