|
1 | | -# DevLorem |
| 1 | +<h1 align="center">DevLorem</h1> |
2 | 2 |
|
3 | | -Show paragraphs of real text ready to copy and paste. No more "Lorem ipsum dolor", get some lines from President Obama, |
4 | | -Jim Carrey or Morgan Freeman. |
| 3 | +<p align="center"><b>Real quotes ready to copy and paste. No more "Lorem ipsum dolor".</b><br>Get some quotes from President Obama, |
| 4 | +Samuel L Jackson, Daisy Ridley or Morgan Freeman!</p> |
5 | 5 |
|
6 | | - |
| 6 | +<p> </p> |
7 | 7 |
|
8 | | -## Get Quotes via API |
| 8 | +<img src="/preview.png" alt="DevLorem Preview"> |
| 9 | + |
| 10 | +<p> </p> |
| 11 | + |
| 12 | + |
| 13 | +## About DevLorem |
| 14 | + |
| 15 | +DevLorem is a small tool that generates Lorem Ipsum paragraphs from movie quotes, based on the different actors. |
| 16 | +It can be used as a command line tool, or can be run as a website that offers both a user interface to generate the |
| 17 | +paragraphs and an API. |
| 18 | + |
| 19 | + |
| 20 | +--- |
| 21 | + |
| 22 | + |
| 23 | +## Download DevLorem |
| 24 | + |
| 25 | +The latest version of the tool can be found on the [releases page](https://github.com/Kovah/DevLorem/releases). |
| 26 | +Please download the archive file of the latest release suitable for your operating system. Unpack the zip and make the |
| 27 | +binary executable. |
| 28 | +Alternatively, you can use the Docker image. Details about the usage can be found further down. |
| 29 | + |
| 30 | + |
| 31 | +## The command line tool |
| 32 | + |
| 33 | +The command line tool can be used to quickly generate paragraphs within your terminal or in scripts. It is available |
| 34 | +as the `generate` command and has some optional parameters. |
| 35 | + |
| 36 | +``` |
| 37 | +devlorem generate |
| 38 | +``` |
| 39 | + |
| 40 | +Usage: |
| 41 | + devlorem generate [flags] |
| 42 | + |
| 43 | +Flags: |
| 44 | + -f, --format string Format of the returned paragraphs, either json or text (default json) |
| 45 | + -h, --help help for generate |
| 46 | + -n, --number int Number of paragraphs returned (default 5) |
| 47 | + -p, --paragraphs Show paragraph tags (<p> and </p>) in the generated paragraphs |
| 48 | + |
| 49 | + |
| 50 | +#### Examples |
| 51 | + |
| 52 | +* `devlorem generate` would get you 5 quotes in JSON without `<p>` tags |
| 53 | +* `devlorem generate -n 15 -p` would get you 15 quotes in JSON including the `<p>` tags |
| 54 | +* `devlorem generate -n 30 -p -f text` would get you 30 quotes as plain text including the `<p>` tags |
| 55 | +* `devlorem generate -n 60 -f text` would get you 60 quotes as plain text without `<p>` tags |
| 56 | + |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | + |
| 61 | +## The website (user interface + API) |
| 62 | + |
| 63 | +The DevLorem executable ships with a built-in web server including all static assets. You can start the web server by |
| 64 | +using the `serve` command. By default, the started web server listens to port 80 on your host. |
| 65 | + |
| 66 | +``` |
| 67 | +$ devlorem serve |
| 68 | +Starting HTTP server for DevLorem... |
| 69 | +``` |
| 70 | + |
| 71 | +You can now open DevLorem in your browser under `http://localhost`. |
| 72 | + |
| 73 | +If you want to use another port, you can use the optional bind flag. To change the port, specify the port including |
| 74 | +preceding colon. In the following example we tell DevLorem to use the port 8090: |
| 75 | + |
| 76 | +``` |
| 77 | +devlorem serve -b :8090 |
| 78 | +``` |
| 79 | + |
| 80 | + |
| 81 | +### Usage of the website API |
| 82 | + |
| 83 | +Once the web server is started, the DevLorem API is available too. In the following examples I assume that you have set |
| 84 | +up DevLorem behind a proxy with the domain `your-domain.com` and HTTPS configured. |
9 | 85 |
|
10 | 86 | Required URL structure: |
11 | | -`your-domain.com/api/[int][/p][/json]` |
| 87 | +`https://your-domain.com/api/[int]` |
| 88 | + |
| 89 | +* The results will be returns as Json by default. |
| 90 | +* The maximum allowed amount of quotes is `99`. |
| 91 | +* Append `paragraphs=true` as a query parameter to show paragraph tags in the output. |
| 92 | +* Append `format=text` as a query parameter to get plain text output. |
12 | 93 |
|
13 | | -* [int] = optional, number of paragraphs you want |
14 | | -* [/p] = optional, select if the `<p>` tags should be included |
15 | | -* [/json] = optional, output the data in JSON format |
16 | 94 |
|
17 | 95 | #### Examples |
18 | 96 |
|
19 | | -* `your-domain.com/api/15/p/json` would get you 15 paragraphs in JSON including the `<p>` tags |
20 | | -* `your-domain.com/api/5/json` would get you 5 paragraphs in JSON without `<p>` tags |
21 | | -* `your-domain.com/api/100/p` would get you 100 paragraphs as plain text including the `<p>` tags |
22 | | -* `your-domain.com/api/100` would get you 100 paragraphs as plain text without `<p>` tags |
| 97 | +* `https://your-domain.com/api/5` would get you 5 quotes in JSON without `<p>` tags |
| 98 | +* `https://your-domain.com/api/15?paragraphs=true` would get you 15 quotes in JSON including the `<p>` tags |
| 99 | +* `https://your-domain.com/api/30?paragraphs=true&format=text` would get you 30 quotes as plain text including the `<p>` tags |
| 100 | +* `https://your-domain.com/api/60?format=text` would get you 60 quotes as plain text without `<p>` tags |
| 101 | + |
| 102 | + |
| 103 | +--- |
| 104 | + |
| 105 | + |
| 106 | +## The DevLorem Docker image |
| 107 | + |
| 108 | +DevLorem is also available as a [Docker image](https://hub.docker.com/r/kovah/devlorem). It is built using Alpine |
| 109 | +Linux and is less than 10 MB large. |
| 110 | + |
| 111 | +To use the command line tool, run the Docker image with the `generate` command. More details about the tool can be |
| 112 | +found in the command line documentation above. |
| 113 | + |
| 114 | +``` |
| 115 | +docker run --rm kovah/devlorem generate |
| 116 | +``` |
| 117 | + |
| 118 | +To use the website, you have to additionally forward a port. Please notice that DevLorem does not support HTTPS |
| 119 | +connections, so you probably need a proxy in front of it. |
| 120 | +You can start the web server by using the `serve` command. More details about the command can be found in the website |
| 121 | +documentation above. |
| 122 | + |
| 123 | +``` |
| 124 | +docker run --rm -p 80:80 kovah/devlorem serve |
| 125 | +``` |
| 126 | + |
23 | 127 |
|
24 | 128 | --- |
25 | 129 |
|
26 | | -### Contribution |
| 130 | + |
| 131 | +## Contribution |
27 | 132 |
|
28 | 133 | Want to contribute more source texts? Please create a pull request for the new file that should follow the exact same |
29 | 134 | styling like the ones that are already available: |
30 | 135 |
|
31 | | -* Name the file by the person or thing you want to reference. |
32 | | -* The text file should not contain special characters but can contain spaces. |
33 | | -* Place all paragraphs into `<p></p>` tags. |
| 136 | +* Filename must contain the name (lowercase, spaces replaced with dashes). |
| 137 | +* The JSON strcuture must match the existing files. |
| 138 | +* Do not use any <p> tags in the quotes. |
| 139 | + |
34 | 140 |
|
35 | 141 | --- |
36 | 142 |
|
| 143 | + |
| 144 | +## Development and Compilation |
| 145 | + |
| 146 | +### Development |
| 147 | + |
| 148 | +You need the following packages on your machine to be able to work on DevLorem and compile the binary: |
| 149 | + |
| 150 | +* github.com/spf13/cobra |
| 151 | +* github.com/gorilla/mux |
| 152 | +* github.com/GeertJohan/go.rice |
| 153 | +* github.com/GeertJohan/go.rice/rice |
| 154 | + |
| 155 | +This can be done by running `go mod download` in the current project directory. |
| 156 | + |
| 157 | +To test the package, compile it and then run the resulting executable. I recommend using [Goland]() |
| 158 | +for local development. |
| 159 | + |
| 160 | + |
| 161 | +### Compilation |
| 162 | + |
| 163 | +To compile the binary and run it locally in the same folder, run the following command: |
| 164 | + |
| 165 | +``` |
| 166 | +go build |
| 167 | +``` |
| 168 | + |
| 169 | +To generate a single binary without any dependencies, you have to generate the needed content file for that: |
| 170 | +``` |
| 171 | +rice embed-go |
| 172 | +# then run the build command |
| 173 | +go build |
| 174 | +``` |
| 175 | + |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | + |
37 | 180 | DevLorem is a project by [Kovah](https://kovah.de) | [Contributors](https://github.com/Kovah/DevLorem/graphs/contributors) |
0 commit comments