Package url2png uses the url2png service to take screenshots of websites.
The Defacto2 application is a self-contained web server first devised in 2023. It is built with the Go language and can be easily compiled for significant server operating systems. The application relies on a PostgreSQL database setup for data queries using a PostgreSQL database connection. All configurations and modifications to this web application's default settings are through system environment variables. While you can compile the application to target Windows environments, it is ill-advised as it needs to work correctly with NTFS file paths. Instead, it is advisable to use Windows Subsystem for Linux. While it will not be fully functional without directory paths or a database connection, the web server will work out of the box without any configuration provided. Usage: The web server should be available at the unencrypted address, http://localhost:1323. There are only two additional commands: one lists the accessible addresses the web server listens on, and the other lists the detected settings. Usage: The commands are: Usage: The flags are: All application configurations and default modifications are made with environment variables. In systemd, these can be provided using a system service (unit) file, using the Environment assignment under the Service type. You can use an example of a defacto2.service unit file, which is found in the source code repository in the init/ directory. A partial example of a defacto2.service unit file: This application expects a PostgreSQL database with the Defacto2 "files" table and the connection URL configured in the D2_DATABASE_URL environment variable. The database connection URL uses a configuration by default but will fail to connect unless the testing Postgres database matches the same values. In production, you must provide a secure and working connection D2_DATABASE_URL variable. The default database connection URL is: postgres://root:example@localhost:5432/defacto2_ps Some examples: The web server uses the following environment variables to offer file downloads, software emulation, web server previews, and thumbnails. All paths must be absolute and valid and must contain tens of thousands of asset files named with universal unique identifiers. The website will turn off the associated feature if the provided path is invalid or contains unexpected files. D2_DIR_DOWNLOAD is the absolute path to the file downloads directory. D2_DIR_PREVIEW is the absolute path to the image screenshots directory. D2_DIR_THUMBNAIL is the absolute path to the squared, image thumbnails directory. D2_DIR_ORPHANED is the absolute path to the orphaned files directory. D2_DIR_EXTRA is the absolute path to the extra files directory. An example download setting: When the application runs in production mode, errors or warnings caused by the web server are saved to a log file. The location can be provided using the D2_DIR_LOG variable, which must point to an absolute directory path. Otherwise, the server will create a subdirectory using os.UserConfigDir. An example log setting: The web server uses Google OAuth2 for administrator logins. The server requires a Google OAuth2 client ID to validate admin logins, which is provided in the D2_GOOGLE_CLIENT_ID environment variable. The server also requires a list of Google OAuth2 user accounts, which is provided in the D2_GOOGLE_ACCOUNTS environment variable. A user account is the JWT "sub" field assertion in the form of a unique integer. An example accounts setting: The production mode is on by default and should be enabled in production as it has the following effects. To turn off production mode: Read-only mode blocks any website feature that writes to the server database, including the Uploader and administrator database entry edits. To turn off the read-only mode: The no crawler mode inserts an X-Robots-Tag with the "none" value for all network response headers sent by the web server. The header advises search engines and other bots not to index the website or assets. To enable no crawl mode: When quiet is turned on, the majority of startup messages are suppressed. This option is meant for systemd to avoid spamming its log. To enable quiet mode: The web server will listen to all HTTP requests on port 1323 without configuration. The value can be changed with the D2_HTTP_PORT variable, which can be set to 0 to disable HTTP. The D2_TLS_PORT variable, which is turned off by default, allows for an encrypted HTTPS service. In a production situation, you should supply the D2_TLS_CERT and D2_TLS_KEY variables. These should have an absolute path to a TLS (Transport Layer Security) certificate file and key file. If no certificate or key is provided, a dummy certificate will be used, but browsers will reject these. If the D2_HTTP_PORT and the D2_TLS_PORT values are set to 0, the web server will override to enable port 1323 for HTTP connections. On Linux, ports 1-1023 are considered well-known and reserved for the operating system. Providing a D2_MATCH_HOST variable can restrict the web server from listening to HTTP and HTTPS requests from a single IP address or host. Otherwise, the web server listens to all requests on the ports. An example configuration to exclusively use HTTPS and only accept local connections: