redditbooru / reddit-booru

An aggregator that takes images from various subreddits and wraps a nice interface around them with advanced search features.
54 stars 10 forks source link

RedditBooru


What is it?

RedditBooru is an image board site driven by content posted to subreddits.

Advanced Searching

Keyword search can be done and, while not as powerful as reddit's search, it's a goodly bit faster (I like to think). But, what RedditBooru provides above reddit or karmadecay is reverse image searching. This allows users to keep content reposting to a minimum. The search algorithm isn't perfect, but it works most of the time.

Image Hosting

Content hosting through RedditBooru ensures that what's uploaded is exactly what the end users will receive, no middle-man processing, scaling, or JPEGifying in between. Additionally, the original source can be directly attributed to an image so that proper props can be given. Galleries can also be created and modified thanks to login support via reddit OAuth.

Reddit Voting

Taking advantage of the aforementioned reddit OAuth, RedditBooru allows users to vote on images right through the site's interface. Combined with the fullscreen viewer, this makes browsing many subreddits worth of images very simple (and hopefully a nicer experience).

Are there any new features in the works?

RedditBooru is never finished! Here are some ideas that are being worked on/in the thought bucket:

I'd like to help. What can I do?

If you're here, you know the code is completely open for anybody to hack on. Found a bug or have a great idea? Open a ticket and we'll see what can happen. Want to write that code yourself? Make a pull request! Obviously, I can't guarantee that all requests will make it to the site (gotta make sure all works, and that features won't bring the server to its knees), but I'm very much open to people contributing. For help setting up your development environment, check out the next section.

Development Setup

If you want to get RedditBooru up and running for yourself, follow these steps.

NOTE - As RedditBooru prepares to move towards a more modular, microservice structure, this is all highly subject to change. Currently it's a mess, and it needs to be made not a mess.

Pre-requisites

You will need the following to run RedditBooru:

Initial Setup

Assuming you have all of the above:

# Get the code
git clone https://github.com/dxprog/reddit-booru.git
cd reddit-booru

# Create the backend cache directory and make it writeable
mkdir cache
chmod 777 cache/

# Install composer packages
composer install

# Install node dependencies
npm install

# Assuming you have an empty database set up, create the schema
mysql -u YOUR_USER -p -D reddit-booru < schema.sql

# Build front end files
npm run build

Configuration

RedditBooru can be setup to run multiple frontends with a single backend (though some work is still needed). Given that, there are two configuration files:

Paths

You can happily run the entirety of RedditBooru from the same directory. If you want split up backend and front-end, here's what you need to know:

Backend (not accessible by web server)
Frontend (point your web server here)

URL Rewrites

RedditBooru expects the entire URL path to be passed in as the query string parameter _q and handles additional query string paremeters/routing itself. Example of nginx setup:

location / {
  try_files $uri $uri/ /index.php?_q=$uri;
}

Adding a Source

Sadly, this is a very manual process currently, requiring direct entry into the database. It's not difficult, just tedious. Here's what you need to know about the fields:

Getting Content

Content is inserted in one of two ways:

cron/cron.php

To manually update content, run the following from the backend directory:

php cron/cron.php --source=SOURCE_ID

This will scan that source and update/insert the latest 100 items. This can be run as a cron job for continual updates.

Service

The set-it-and-forget-it node script to continually updates all enabled sources. Using either screen (or some other detached-like terminal) or something like forever, run:

node services/task-runner.js

This service does currently have a hard coded URL to the API that returns all sources. Locate http://redditbooru.com/sources/ in task-runner.js and replace with the appropriate path. THIS IS GOING TO BE REPLACED WITH EXTERNAL SERVICE NODES VERY SOON!

Additional Services

There are some additional services rolled up into the main RedditBooru codebase. It's all very hacked together, so please excuse the mess.

SauceNao

The SauceNao service is a node script that manages requests for getting image sources via SauceNao without going over API limits. To get it running:

# SauceNao API key
export SVC_SAUCENAO_KEY = SAUCENAO_API_KEY

# Port to run the service on. SAUCENAO_PORT in config.php should be this same value. Someday, it'll use the env var too.
export SVC_SAUCENAO_PORT = 4444

# Run it. Use screen/forever/init.d script to persist
node services/saucenao-service.js

cron/clean.php (DEPRECATED)

Used to remove old cached files. It's recommended that you use find on a cron job instead.

ai-tan (DEPRECATED)

"ai-tan" provides a couple of features on two different scripts:

These scripts rely on an old PHP based reddit framework of mine that's terrible and outdated. Setting this up is non-trivial and won't be covered here as they are actively being replaced by better, stand-alone modules.