GithubHelp home page GithubHelp logo

books's Introduction

books

This is a node.js server for hosting a directory full of books. It can host other things, I suppose, but books are what it's made for.

This server is not meant to be open to the public, though it can be if you make the necessary modifications. Authentication is handled through Discord, where users who are a member of servers specified in config.json can access this book directory.

Configuration

A file named config.template.json is provided with this source code. To set up this server, rename the template to config.json and fill in the fields as follows:

{
    "discord": {
        "id": "", // the ID of your Discord app (create in Discord API)
        "secret": "", // your Discord API secret
        "servers": [], // a list of IDs of servers (as strings). users must be in one of these servers to access books
        "users": [] // a list of IDs of users (as strings) to specifically whitelist. users listed here don't need to be in any of the above servers to access books
    },
    "s3": {
        "endpoint": "https://s3.wasabisys.com", // the S3-compatible endpoint to use
        "id": "", // the AWS access key for the bucket used to store books
        "secret": "", // the AWS secret key for the bucket used to store books
        "bucket": "" // the bucket used to store books
    },
    "path": "", // the path to the data folder (see next section)
    "port": 3001,
    "secret": "", // should be a random string, used for sessions
    "share_secret": "", // should be a different string, used for sharing
    "url": "http://localhost:3001", // the url of the web page
    "share_length": 3600, // length in seconds that a share link works for
    "title": "books": // the title of the web page
}

Data

Books are now stored in an S3-compatible bucket specified in the config file. Books can be of any file type you wish, and you can include multiple file types of the same book (as long as they have the same file name).

Inside your data folder must be a JSON file named books.json, which specifies the metadata for every book. The file should look something like this:

{
    "_categories": ["Fiction", "Non-Fiction", "Other"],
    "book": {
        "title": "The Name of the Book", // if not set, title will be the filename of the book
        "authors": ["Author One", "Author Two", "Etc"], // if not set, book will have no authors
        "category": "Fiction" // if not set, book will be placed in "Other"
    }
}

For example, if I added "Tunnel in the Sky" by Robert A. Heinlein to the bucket, and I had it in epub, mobi, pdf, and htmlz formats, I would add every format to the bucket under the name "Tunnel in the Sky" (so "Tunnel in the Sky.pdf", "Tunnel in the Sky.epub", etc) and I'd add this to books.json:

{
    "_categories": ["Fiction", "Other"],
    "Tunnel in the Sky": {
        "title": "Tunnel in the Sky", // not really needed because it's the same as the filename
        "authors": ["Robert A. Heinlein"],
        "category": "Fiction"
    }
}

Now, all four formats will be under the same listing, under the "Fiction" category.

License

Copyright 2023 Ashley Rogers

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

books's People

Contributors

azrogers avatar

Watchers

 avatar

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.