diff --git a/README.md b/README.md index 150b6c72bd57968c0674fadae265327151620222..d512a019526a4e9c9979bedad2e0f04caa79275f 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,74 @@ -# Mastodon Glitch Edition # +# Glitch-fe: glitch-soc frontend for pleroma -> Now with automated deploys! +Here is a fork of mastodon. We could really just remove all of the code except +for the frontend, but to easily pull the upstream repo we'll just keep +everything. This is my fork for the moment with the idea of making the mastofe +just as polished as the pleromafe. If you want to get access, open an issue or +hit me up at howl@social.zxq.co. -[![Build Status](https://img.shields.io/circleci/project/github/glitch-soc/mastodon.svg)](https://travis-ci.org/glitch-soc/mastodon) +# Development -[circleci]: https://circleci.com/gh/glitch-soc/mastodon +I use a combination of the pleroma backend + yarn + nginx to do local +development. I refuse to install Ruby. Here's how to get it running on your own +machine: -So here's the deal: we all work on this code, and then it runs on dev.glitch.social and anyone who uses that does so absolutely at their own risk. can you dig it? +## Install yarn -- You can view documentation for this project at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/). -- And contributing guidelines are available [here](CONTRIBUTING.md) and [here](https://glitch-soc.github.io/docs/contributing/). +Yarn will be needed to set up the mastodon frontend for development. Check out +https://yarnpkg.com/lang/en/docs/install/ . For Debian, it's like this: + +```sh +# import yarn pub key and repo +curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - +echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +sudo apt-get update +sudo apt-get install yarn +``` + +## Mastodon Frontend Setup + +```sh +# Install dependencies +yarn install -D +npm run dev +# check that http://localhost:3035/packs/common.css works in your browser once +# webpack is done compiling. if css shows up, then it should have worked! +``` + +## nginx setup + +I'll assume that you have already fired up pleroma using the installation guide. +To work on the frontend while still having the backend up, use this nginx +config. + +``` +server { + listen 80; + server_name pleroma.testing; + + location /packs { + add_header 'Access-Control-Allow-Origin' '*'; + proxy_http_version 1.1; + proxy_set_header Host $http_host; + + proxy_pass http://localhost:3035; + } + + location / { + add_header 'Access-Control-Allow-Origin' '*'; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $http_host; + + proxy_pass http://localhost:4000; + } +} +``` + +Change the `server_name` if you like. I personally like to create a new entry +in /etc/hosts and add `127.0.0.1 pleroma.testing`, but you do what suits you. + +If you have enough luck, navigating to your \/web should show +you the mastodon frontend, and should also work with all the nice things of +webpack such as hot reloading. Have fun! diff --git a/app/javascript/mastodon/api.js b/app/javascript/mastodon/api.js index 0be08d7fdd8fdd8dc4805376eddbe10f5ccd543d..580d1af974abf196d67006966dbbd29c01f808a4 100644 --- a/app/javascript/mastodon/api.js +++ b/app/javascript/mastodon/api.js @@ -1,5 +1,4 @@ import axios from 'axios'; -import ready from './ready'; import LinkHeader from './link_header'; export const getLinks = response => { @@ -12,17 +11,10 @@ export const getLinks = response => { return LinkHeader.parse(value); }; -let csrfHeader = {}; -function setCSRFHeader() { - const csrfToken = document.querySelector('meta[name=csrf-token]').content; - csrfHeader['X-CSRF-Token'] = csrfToken; -} -ready(setCSRFHeader); - export default getState => axios.create({ - headers: Object.assign(csrfHeader, getState ? { + headers: getState ? { 'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`, - } : {}), + } : {}, transformResponse: [function (data) { try { diff --git a/package.json b/package.json index 5636cb88370f33946edb44038a57a086b38f5f48..b8b264d9e422276d820057f547e1bca803804d7e 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "build:development": "cross-env RAILS_ENV=development ./bin/webpack", "build:production": "cross-env RAILS_ENV=production ./bin/webpack", "manage:translations": "node ./config/webpack/translationRunner.js", + "dev": "cross-env NODE_ENV=development webpack-dev-server --config config/webpack/development.js --progress --color", "start": "node ./streaming/index.js", "test": "npm-run-all test:lint test:jest", "test:lint": "eslint -c .eslintrc.yml --ext=js app/javascript/ config/webpack/ streaming/",