- PHP 71.9%
- CSS 28.1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| actions | ||
| css | ||
| data | ||
| fonts/Lexend | ||
| js | ||
| media | ||
| .gitattributes | ||
| .gitignore | ||
| add_form.php | ||
| config.json | ||
| index.php | ||
| media.php | ||
| media_list.php | ||
| media_search.php | ||
| media_sort.php | ||
| README.md | ||
book-list
A lightweight php-based list solution for your media
Requirements
- A webserver (with write access to the cloned directory)
- PHP 7.0 or higher
Installation
- Clone the repository to your webserver
- Acecss the directory via your web browser
- done
Usage
Adding a new list
- If you are inside a list, click the
backbutton (<-) in the bottom left corner - Enter the name of the new list in the input field (you cannot use a name that is already in use)
- Press the
gobutton (->) to create the new list
Deleting a list
- If you are inside a list, click the
deletebutton (trashcan) in the bottom right corner
Adding a new entry
- Choose the type of media you want to add from the dropdown menu
- Fill out the form
- Press the
+button to add the entry
Editing an entry
- Click on the entry or hover over the entry and click the
editbutton - Edit the entry in the form
- Press the
savebutton (checkmark) to save the changes (or thecancelbutton (x) to discard the changes)
Deleting an entry
- Click on the entry or hover over the entry and click the
deletebutton
Searching for an entry
- Enter the search term in the search field in the top left corner
- Press the
searchbutton (magnifying glass) to search for the term
Sorting the list
- Select the sorting method from the dropdown menu in the top left corner (below the search field)
- If you choose
custom, you can click on or hover over an entry and then click themovebuttons (< >) to move the entry to a different position
Adding a list to another website via an iframe
- On the website you want to add the list to, create an iframe element. It should look like this:
<iframe src="https://your-domain.com/path/to/book-list/actions/to-view?dir=<list-name>" frameborder="0" allowtransparency="true"></iframe><list-name>: The name of the list you want to add.
- Set the width and height of the iframe to the desired size.
Adding a single entry to another website via an iframe
- On the website you want to add the entry to, create an iframe element. It should look like this:
<iframe src="https://your-domain.com/path/to/book-list/actions/single-view?type=<media-type>&title=<title>" frameborder="0" allowtransparency="true"></iframe><media-type>: The type of the media you want to add. For example, if you want to add a book, you would usebookas the media type.<title>: The title of the media you want to add.
- Set the width and height of the iframe to the desired size.
Configuration
Changing the storage location
- Open the config.json file.
- Change the
storage-foldervariable to the path of the directory you want to use for storage. - Create the directory if it does not exist.
- Make sure the webserver has write access to the directory.
Changing the color theme
-
Open the css/main-page.css file.
-
Set the color variables in the
:rootselector to the colors you want to use.--color-mainUsed for the menu--color-secondaryUsed for buttons--color-backgroundUsed for the background--color-accentUsed for the hover and editing effect--color-textUsed for text--color-text-secondaryUsed for less important text--color-shadowUsed for shadows
Adding new types of media
- Create a new entry in the
typeslist in config.json. It should look like this:"<type-name>": { "icon": "<icon-name>", "artist-name": "<artist-name>", "category": "<category>", "key-file": "<key-file>", "layout": "<layout>" },<type-name>: The name of the type. This is what you will use to identify the type later on. For example, if you want to add a new type called "book", you would usebookas the type name.<icon-name>: The name of the icon that will be used for this type. We use Google's Material Icons for this. You can find the name of the icon you want there. For example, if you want to use theMusic Noteicon, you would use that as the icon name.<artist-name>: The name of the artist. This is what will be displayed in the form when adding a new entry. For example, if you want to add a new type calledmovie, you would useDirectoras the artist name.<category>: The category of the media. This determines where the media will be displayed in the dropdown menu. This should be a number between 0 and 3. The categories are as follows:- 0: Reading
- 1: Watching
- 2: Listening
- 3: Playing
<key-file>: The name of the file that will contain your api-key information. Before letting the user add an entry the site will check if the file exists and contains some information. If it does not, the type will not be displayed in the dropdown menu. The files are located in the data directory. For example, if you want to add a new type calledsong, you could create a file calledspotify_key.txtin the data directory and usespotify_keyas the key file. If you do not need an api key, you can leave this empty.<layout>: The layout of the entry. This determines how the entry will be displayed in the list. This should be one of the following:- "" (empty): The entry will be displayed in a book like format.
- "squared": The entry will be displayed in a squared format.
- "landscape": The entry will be displayed in a landscape format.
- Create a
get_<type-name>_data.phpfile in the actions/apis directory. - Write a
get_datafunction. It should look like this:
<?php
function get_data($data_reset, $title, $author, $image, $length, $link)
{
$key = file_get_contents("../data/<key-file>.txt");
/// Authorize at the API Service
//get info from Service
$url = "https://api.service.com/v1/search?q=" . urlencode($title) . ($author != null && $author != "" ? urlencode(" " . $author) : "");
$service_search_json = file_get_contents($url);
$service_search = json_decode($service_search_json, true);
// did we get results?
if (count($service_search["albums"]["items"]) == 0) {
if ($data_reset) {
$author = "Unknown";
$image = "none";
$length = "Unknown";
}
} else {
if ($author == null || $author == "") {
$author = $service_search[...]["artist"];
}
if ($image == null || $image == "") {
$image = $service_search[...]["imge_url"];
}
if ($length == null || $length == "") {
// Number of tracks
$length = $service_search[...]["time_ammount"];
}
}
return array($author, $image, $length, $link);
}
?>
The following types already exist and use the following apis:
- book (google books)
- movie (omdb)
- series (omdb)
- video (youtube)
- song (spotify)
- album (spotify)
- game (rawg)
The youtube, spotify and rawg apis require an api key. You can get one for free at the following links:
The api keys should be stored in the data directory. The file names should be the same as the key-file in the config.json file. They should be stored in the following format:
youtube_key.tyt
<key>
spotify_cid_cis.txt
<client-id>
<client-secret>
rawg_key.txt
<key>
Contributing
If you want to contribute, feel free to open a pull request.