pifi 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0b52109a7d2e0f8ce6fa62b9c87a13079966c6d9cdc4d88bdfb76245e3fad95
4
- data.tar.gz: 7250d4469717c956e0fbb81d066fa3a12ac22f934d6cbfbcb69f74a769dde09c
3
+ metadata.gz: 9e438554830dd34a08a8bbd6c1b50147bd3a57fcd83375ff650ac2e250d13af5
4
+ data.tar.gz: 5994a88287ab9c58f799cec839f7a2d84d5f2ba849002faba2475769176c6fe0
5
5
  SHA512:
6
- metadata.gz: c03d08825762b9a79f93359aa42150a77dbc9d3f7133773bf3e2e974827413693ba47c304a8b78a9e050d1648aa45be98b62b623b70053b8b0ac375f51798f46
7
- data.tar.gz: d851d8ba1e665ed37620f9ebee9c78d0dee371ebbf0ea80d6835f2e3b04b756ba4554d416ed6544c684e8d1a0c2044a8180a735589bcd282dc160d083b3a9275
6
+ metadata.gz: fcdd705b344569802b03a03cc0447c8c0b2b6b1dbf2256ba01cf659f46ed2efc901537ea02cf02841610d613e584442c047589fc2a2609bb1fb3bd53327ee0ec
7
+ data.tar.gz: 843cc7461a81904893dfc052451849eedf3aa36197ede2b2f6cc0dba60b97e6df3f697e9941f6b5f2088af3b14bfd0cf5c30f7f434ed5366a764dcfc4c3411a8
data/INSTALL.md CHANGED
@@ -21,10 +21,11 @@ $ sudo systemctl start mpd && sudo systemctl enable mpd
21
21
  $ sudo gem install pifi --no-ri --no-rdoc
22
22
  ```
23
23
 
24
- 4. To run PiFi, you'll need a list of radios at `/etc/pifi_streams.json`. Paste this for now:
24
+ 4. To run PiFi, you'll need a list of radios at `/etc/pifi/streams.json`. Paste this for now:
25
25
 
26
26
  ```
27
- sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi_streams.json.sample -O /etc/pifi_streams.json
27
+ $ sudo mkdir -p /etc/pifi
28
+ $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/streams.json.sample -O /etc/pifi/streams.json
28
29
  ```
29
30
 
30
31
  Later, you can edit that JSON file [as described here](README.md#list-of-streams).
@@ -34,8 +35,8 @@ Later, you can edit that JSON file [as described here](README.md#list-of-streams
34
35
  Download a sample and edit [following the documentation](README.md#pifi-configuration):
35
36
 
36
37
  ```
37
- $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi.json.sample -O /etc/pifi.json
38
- $ sudo -e /etc/pifi.json
38
+ $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/config.json.sample -O /etc/pifi/config.json
39
+ $ sudo -e /etc/pifi/config.json
39
40
  ```
40
41
 
41
42
  **Done!** You can now run PiFi with `pifi` and reach it at `http://DEVICE_IP:3000`. Type `pifi -h` to check the options available.
@@ -59,3 +60,7 @@ $ sudo -e /etc/systemd/system/pifi.service
59
60
  ```
60
61
 
61
62
  **Done!** Now you can start PiFi with `sudo systemctl start pifi`. For running at boot, enter `sudo systemctl enable pifi`.
63
+
64
+ ## Advanced deployments
65
+
66
+ If you need something different from this, [check this document](docs/install_tips.md).
data/README.md CHANGED
@@ -67,20 +67,37 @@ Although PiFi tries to be minimal, there are some neat features, such as:
67
67
 
68
68
  ## Installation
69
69
 
70
- While PiFi was imagined for the Pi, it should run on any computer with:
70
+ While PiFi was imagined for the Pi, it should run on any computer with Ruby and MPD.
71
71
 
72
- - Ruby and a few gems
73
- - MPD
72
+ Install it with:
74
73
 
75
- [Check the installation guide](INSTALL.md).
74
+ ```
75
+ $ sudo gem install pifi --no-ri --no-rdoc
76
+ ```
77
+
78
+ Place a list of streams at `/etc/pifi/streams.json`:
79
+
80
+ ```
81
+ $ sudo mkdir -p /etc/pifi
82
+ $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/streams.json.sample -O /etc/pifi/streams.json
83
+ ```
84
+
85
+ Make sure MPD is running and start PiFi:
86
+
87
+ ```
88
+ $ sudo systemctl start mpd
89
+ $ pifi
90
+ ```
91
+
92
+ For more detailed steps, [check the installation guide](INSTALL.md).
76
93
 
77
94
  ## Configuration
78
95
 
79
96
  ### List of streams
80
97
 
81
- PiFi needs a list of the radios you want to listen. [A example is available here](docs/pifi_streams.json.sample).
98
+ PiFi needs a list of the radios you want to listen. [A example is available here](docs/streams.json.sample).
82
99
 
83
- The list is read by default from `/etc/pifi_streams.json`. You can change this path [creating a configuration file](#pifi-configuration).
100
+ The list is read by default from `/etc/pifi/streams.json`. You can change this path [creating a configuration file](#pifi-configuration).
84
101
 
85
102
  To keep it simple, the list of streams is just a JSON file with key-value pairs, where the key is the station name, and the value is the streaming URL. For example:
86
103
 
@@ -105,15 +122,15 @@ If you want to arrange the stations in categories, add a pair with the category
105
122
 
106
123
  It's now completely optional to have a configuration file for PiFi. You only need one if you want something different from the defaults.
107
124
 
108
- The path is `/etc/pifi.json` and these are the options:
125
+ The path is `/etc/pifi/config.json` and these are the options:
109
126
 
110
127
  | Key | Default | Description |
111
128
  | --------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------- |
112
129
  | `mpd_host` | `127.0.0.1` | MPD host. |
113
130
  | `mpd_port` | `6600` | MPD port. |
114
131
  | `mpd_password` | `""` (none) | MPD password. |
115
- | `streams_file` | `/etc/pifi_streams.json` | Path to the JSON file containing the streams. |
116
- | `streamsp_file` | `""` (none) | Path to JSON file containing additional streams. These will be shown only to the devices listed on `special_ips`. |
132
+ | `streams_path` | `/etc/pifi/streams.json` | Path to the JSON file containing the streams. |
133
+ | `streams_path_priv` | `""` (none) | Path to JSON file containing additional streams. These will be shown only to the devices listed on `special_ips`. |
117
134
  | `special_ips` | `""` (none) | The IPs of the devices to show additional streams. |
118
135
  | `play_local` | `false` | Set it to `true` if you want PiFi to play songs from your local library. This shows the "Random" button. |
119
136
  | `serve_static` | `true` | If we should serve static resources. Set it to `false` if your web server is already doing it. |
@@ -121,8 +138,9 @@ The path is `/etc/pifi.json` and these are the options:
121
138
  If you want to change any of these options, download the sample file and edit it to your needs:
122
139
 
123
140
  ```
124
- $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/pifi.json.sample -O /etc/pifi.json
125
- $ sudo -e /etc/pifi.json
141
+ $ sudo mkdir -p /etc/pifi
142
+ $ sudo wget https://raw.githubusercontent.com/rccavalcanti/pifi-radio/master/docs/config.json.sample -O /etc/pifi/config.json
143
+ $ sudo -e /etc/pifi/config.json
126
144
  ```
127
145
 
128
146
  ## Usage
@@ -0,0 +1,41 @@
1
+ # Advanced installation tips
2
+
3
+ Here I list some tips on more advanced PiFi deployments.
4
+
5
+ ## Running on port 80
6
+
7
+ You may want to access PiFi without typing a port, as in `http://pi.local` or `http://pifi.local`.
8
+
9
+ For this, you can install a web server, such as Nginx, Apache or Lighttpd, and set up a reverse proxy. As the precise configuration varies between each of them, please check their documentation.
10
+
11
+ ## Serving static resources from your web server
12
+
13
+ If you set your web server to reverse proxy PiFi, you may also use it to serve PiFi static assets. This possibly brings some performance gains.
14
+
15
+ On PiFi configuration, set `serve_static` to false.
16
+
17
+ On your web server, the exact steps depend on your configuration. You will probably need to set the root of the virtual server to PiFi's static assets directory. This is `${PIFI_DIR}/lib/pifi/public`. Refer to the next section for tips on how to find your `${PIFI_DIR}`. Refer to the documentation of your web server for details.
18
+
19
+ ## Finding PiFi directory
20
+
21
+ This largely depends on how you installed PiFi and your distro.
22
+
23
+ - If you installed it with `sudo gem install pifi` on Raspbian, this should be `/var/lib/gems/*/gems/pifi-*`.
24
+ - If you installed with the `gem` command, run `gem environment` and check the paths below "Gem paths".
25
+ - If you are completely lost, you can always run `find / -iname "pifi*" 2>/dev/null`
26
+
27
+ ## Configuring Thin directly
28
+
29
+ The `pifi` command exposes most Rack CLI options, but you may want to access more advanced configurations from Thin (the application server PiFi uses).
30
+
31
+ To achieve this, instead of invoking `pifi`, run `thin` and pass PiFi's `config.ru` and the `-e production` flag. The former is located at `${PIFI_DIR}/config.ru`.
32
+
33
+ For example, if you want to run PiFi on a socket instead of a port:
34
+
35
+ ```
36
+ $ thin start -R ${PIFI_DIR}/config.ru -e production --socket /var/run/pifi/pifi.sock
37
+ ```
38
+
39
+ ## Using other application server
40
+
41
+ If for some reason you don't want to use Thin as the application server, simply run the one you want and pass a `production` flag and the path for PiFi's config.ru (`${PIFI_DIR}/config.ru`).
@@ -5,7 +5,7 @@ require "sinatra/base"
5
5
  module PiFi
6
6
  class ApplicationController < Sinatra::Base
7
7
  set ConfigGetter.new.config
8
- set :streams, StreamsGetter.new(settings.streams_file, settings.streamsp_file).streams
8
+ set :streams, StreamsGetter.new(settings.streams_path, settings.streams_path_priv).streams
9
9
 
10
10
  set :root, File.expand_path("../../", __FILE__)
11
11
 
@@ -4,13 +4,13 @@ module PiFi
4
4
  class ConfigGetter
5
5
  include Utils
6
6
 
7
- PATH = "/etc/pifi.json"
7
+ PATH = "/etc/pifi/config.json"
8
8
  DEFAULT_KEYS = {
9
9
  "mpd_host" => "127.0.0.1",
10
10
  "mpd_port" => "6600",
11
11
  "mpd_password" => "",
12
- "streams_file" => "/etc/pifi_streams.json",
13
- "streamsp_file" => "",
12
+ "streams_path" => "/etc/pifi/streams.json",
13
+ "streams_path_priv" => "",
14
14
  "special_ips" => "",
15
15
  "play_local" => false,
16
16
  "serve_static" => true
@@ -28,7 +28,7 @@ module PiFi
28
28
  def check_paths
29
29
  raise ArgumentError, "Streams file not found at '#{@path_pub}'" unless File.file?(@path_pub)
30
30
  if ! @path_priv.empty? && ! File.file?(@path_priv)
31
- warn "Additional streams file not found at '#{@path_priv}'"
31
+ warn "Private streams file not found at '#{@path_priv}'"
32
32
  @path_priv = ""
33
33
  end
34
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Cavalcanti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-22 00:00:00.000000000 Z
11
+ date: 2019-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -87,12 +87,13 @@ executables:
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
- - INSTALL.md
90
+ - "./INSTALL.md"
91
+ - "./README.md"
91
92
  - LICENSE
92
- - README.md
93
93
  - bin/pifi
94
94
  - config.ru
95
95
  - docs/icon/license.pdf
96
+ - docs/install_tips.md
96
97
  - lib/pifi.rb
97
98
  - lib/pifi/controllers/application_controller.rb
98
99
  - lib/pifi/controllers/index_controller.rb