/stl_viewer

Responsive gallery

Primary LanguagePython

a simple image gallery to see my collection of STL files. Based on https://github.com/kkosiba/django-gallery but modified a bit everywhere to fit my needs.

The following notes where made when setting it up from scratch on a freshly flashed raspberry pi 3B+

requirement

  • postgres
  • python3
  • install requirements.txt (in a venv if you want)
  • apt-get install libopenjp2-7 libtiff5

Setup

quick notes on the setup (with gunicorn and caddyserver)

in cloned repository:

domain.name

encode gzip zstd

root * /home/pi/stl_viewer/website/

@notStatic {
  not path /static/* /media/*
}

reverse_proxy @notStatic localhost:8000
file_server

features

quick notes on the features

  • django admin available in /admin if you are superuser

Account:

  • an account is needed to see the content
  • Account can be created only in Django admin (/admin)
  • Superuser only can upload new images, change description or tags and delete images

View:

  • header:

    • login/logout/change password button
    • home button
    • if super user there is a link to upload a zip file
  • home:

    • list all tags with at least 1 photo tagged, the display image is random amoung the tagged images
    • the first link is alist all all images
  • tag view:

    • Tags in the first home links to a tag list view, only images with the clicked tag are listed
    • a user with can_tag permission can tag either listing or model or both. These permissions has to be set in the django admin
  • detail view:

    • in detail view you can the description which the path to the stl file in your system (to easily access it if you want to print it)
    • all images linked with this model will be displayed
    • if superuser you have button to edit or delete the images
    • when in editing you can change the searhc image which will be displayed in the other views
    • When editing tags, they are autocompleted, putting a non existant tag will creat it automatically
    • possibility to change displayed images in other views
    • it is possible for a superuser to delete images fro, the detial view.
  • Upload:

    • just select the zip file to upload and go. If the upload fails a quick description of the problem will be displayed
  • Search:

    • the content is splitted in token (separated by spaces)
    • the result of the search is the list images where each token is easier a part of the name or a tag of the images
    • this allow to put multiple tags to norrow down a search
    • it also allow to get all images containing a keyword and having some specific tags
    • a taoken starting with a '!' will remove any model with this token in their name or tags
  • Admin:

    • available at /admin
    • default django admin
    • user account has to be created manually here
    • cann add listing.can_tag and gallery.can_tag permission
  • Listing:

    • The listing symbols next to the home on switch to the listing view.
    • This view has the same features than the gallery but contains links instead of images.

upload structure:

  • have to be a zip
  • have to contain all images to uplaod.
  • have to contain a file named "config.json"
  • json format:
    {                                                                                                                                                                                                               
        "img_names":["file_name1_within_zip_file.png",
		     "file_name1_within_zip_file.png", ...]
        "stl_path":"path/to/your/stl/file/file.stl",                                                                                                                                                           
        "tags":"test42,test2,new_test"                                                                                                                                                                              
    }                                                                                                                                                                                                               
]
  • non-existing tags will be created automatically
  • Also it is possible to update tags of an image via the upload feature. For that "img_names" has to be an empty string and "stl_path" has to match with the image you want to add tags. Again missing tags will be created automatically.
  • If an models with the same stl_path exists, it's tag will be updated with the one in the zip and the image will be replaced by the on in the zip
  • image_names can have as many images thant you want, when creating a new model the first image in img_names will be the one displayed in the all views (but detial vie display all of them)