cheeaun / phanpy

A minimalistic opinionated Mastodon web client
https://phanpy.social
MIT License
935 stars 85 forks source link

Configuration file for pre-built #537

Closed Tealk closed 1 month ago

Tealk commented 1 month ago

Is your feature request related to a problem? Please describe. In order to offer a second web interface for your own Mastodon instance, it would be great if there was a config file in which you could define the default instance, for example.

Describe the solution you'd like A config file for rudimentary settings

Additional context The current situation is that you need Node.js on the server to make changes, which is ok as far as more in-depth settings are concerned.

Something like the PHANPY_PRIVACY_POLICY_URL, for example, is also extremely important in Germany that you can set this. Otherwise you could be fined!

But simple things like the following would be nice if you could also set them: PHANPY_CLIENT_NAME, PHANPY_WEBSITE, PHANPY_DEFAULT_INSTANCE, PHANPY_LINGVA_INSTANCES

cheeaun commented 1 month ago

@Tealk are you currently using the "Custom-build way"? Technically you don't need Node.js to run on the server, it's only needed to build the static files output, not serving them.

Tealk commented 1 month ago

I am currently using the static files because I wanted to introduce the interface to my users. That's why I came up with the idea of offering a configuration for the static files as well, at least for simple rudimentary settings.

cheeaun commented 1 month ago

@Tealk you can try the "Custom-build way" — it'll output static files too but with configuration that's passed in the build command.

Tealk commented 1 month ago

so that doesn't work for me, it ignores the environment variables

PHANPY_CLIENT_NAME="RM Phanpy" \
    PHANPY_WEBSITE="https://phanpy.rollenspiel.social" \
    PHANPY_DEFAULT_INSTANCE="rollenspiel.social" \
    PHANPY_DEFAULT_INSTANCE_REGISTRATION_URL="https://rollenspiel.social/auth/sign_up" \
    PHANPY_PRIVACY_POLICY_URL="https://rollenspiel.monster/privacy" \
    PHANPY_LINGVA_INSTANCES="lingva.adminforge.de" \
    npm run build

https://phanpy.rollenspiel.social

cheeaun commented 1 month ago

@Tealk how are you serving the files?

As for the command above, it'll generate the static files in dist folder.

Tealk commented 1 month ago

Yes, I have uploaded the files from the dist folder to the nginx webserver, which is accessible via the url mentioned above.

cheeaun commented 1 month ago

@Tealk are you on Windows?

Tealk commented 1 month ago

No, client is Fedora, Server is Debian.

I don't know if you are familiar with ansible, but that would be the procedure for updating the site: https://codeberg.org/Tealk/ansible_collection/src/branch/develop/playbook/update-mastodonPhanpy.yml

cheeaun commented 1 month ago

@Tealk I'm not 100% familiar with Ansible.

Does the command work on your local machine? If it works, the dist/index.html file should contain <title>RM Phanpy</title>.

As for Ansible, does it use a different way of setting environment variables? It's possibly stripping out the variables for security reasons, as that's the only reason that I could think of. Regardless, the build script just need to be able to read env variables — powered by dotenv. If it's still not working, the alternative is creating/modifying .env or .env.production file in the root project folder and add your variables there, then run the build script 🙏

Tealk commented 1 month ago

I actually execute all commands locally, wif i execute this command https://github.com/cheeaun/phanpy/issues/537#issuecomment-2108105168 i get a dist folder with index.html but with <title>Phanpy</title>

forget about ansible for now, I just wanted to show you the way I used. Even if I run it manually in the terminal, the variables are ignored.

the alternative is creating/modifying .env or .env.production file in the root project folder and add your variables there, then run the build script 🙏

I tried that too, the variables in the .env were also ignored.

wouldn't it make sense to put the .env in the .gitignore? otherwise the variables will be overwritten/deleted with every pull.

Tealk commented 1 month ago

ok i don't know what the problem was, but i deleted the repo once and cloned it again and then the creation of the page worked as it should. I have also improved the ansible script, thanks for the hint about the variables, I hadn't thought of that.

Tealk commented 1 month ago

If you like, you are welcome to include the ansible script if others also want to automate this.