Skip to content

Commit

Permalink
Merge pull request #128 from icidasset/v2
Browse files Browse the repository at this point in the history
V2
  • Loading branch information
icidasset committed Aug 7, 2019
2 parents bcafa8a + 3711633 commit c24c0bf
Show file tree
Hide file tree
Showing 375 changed files with 22,759 additions and 36,239 deletions.
10 changes: 4 additions & 6 deletions .gitignore
@@ -1,10 +1,8 @@
.stack-work
.DS_Store
.netlify
.tmp.js
*.cabal
/.deploy
/.stack-work
/build
/build-electron
deploy.sh
elm-stuff
node_modules
/elm-stuff
/vendor
3 changes: 1 addition & 2 deletions .tool-versions
@@ -1,2 +1 @@
elm 0.18.0
nodejs 11.10.0
elm 0.19.0
2 changes: 2 additions & 0 deletions FUNDING.yml
@@ -0,0 +1,2 @@
patreon: diffuse
open_collective: diffuse
96 changes: 53 additions & 43 deletions Makefile
@@ -1,12 +1,12 @@
.PHONY: build electron system
.PHONY: build system vendor


# Variables

NODE_BIN=./node_modules/.bin
NPM_DIR=./node_modules
SRC_DIR=./src
BUILD_DIR=./build
BUILD_ELECTRON_DIR=./build-electron
VENDOR_DIR=./vendor


# Default task
Expand All @@ -22,45 +22,36 @@ build: clean elm system vendor
@echo "> Build completed ⚡"


clean:
@echo "> Cleaning Build Directory"
@rm -rf $(BUILD_DIR) || true

build-prod: clean elm-prod system vendor
@echo "> Production build completed 🛳"

electron-clean:
@echo "> Cleaning Electron Directory"
@rm -rf $(BUILD_ELECTRON_DIR) || true


electron-prep:
@echo "> Copying Electron Script"
@cp -r ./electron $(BUILD_DIR)
@cp ./package.json $(BUILD_DIR)/package.json
@echo "> Creating icons"
@mkdir -p $(BUILD_DIR)/resources
@cp $(SRC_DIR)/Static/Images/icon.png $(BUILD_DIR)/resources/icon.png
@makeicns -in $(BUILD_DIR)/resources/icon.png -out $(BUILD_DIR)/resources/icon.icns 2>/dev/null
@convert $(BUILD_DIR)/resources/icon.png -define icon:auto-resize=256 $(BUILD_DIR)/resources/icon.ico
clean:
@echo "> Cleaning build directory"
@rm -rf $(BUILD_DIR) || true


electron-build: build electron-clean electron-prep
@$(NODE_BIN)/electron-builder build --config=electron/builder.yaml --mac --linux --win
elm:
@echo "> Compiling Elm application"
@elm make $(SRC_DIR)/Applications/Brain.elm --output $(BUILD_DIR)/brain.js
@elm make $(SRC_DIR)/Applications/UI.elm --output $(BUILD_DIR)/application.js


elm:
@echo "> Compiling Elm"
@elm-make $(SRC_DIR)/App/App.elm --output $(BUILD_DIR)/application.js --yes
@elm-make $(SRC_DIR)/Slave/Slave.elm --output $(BUILD_DIR)/slave.js --yes
elm-prod:
@echo "> Compiling Elm application (optimized)"
@elm make $(SRC_DIR)/Applications/Brain.elm --output $(BUILD_DIR)/brain.js --optimize
@elm make $(SRC_DIR)/Applications/UI.elm --output $(BUILD_DIR)/application.js --optimize


system:
@echo "> Compiling System"
@echo "> Compiling system"
@stack build && stack exec build


vendor:
@echo "> Copy vendor dependencies"
@stack build && stack exec vendor
@echo "> Copying vendor things"
@mkdir -p $(BUILD_DIR)/vendor/
@cp -rf $(VENDOR_DIR)/ $(BUILD_DIR)/vendor/


#
Expand All @@ -71,25 +62,46 @@ dev: build
@make -j watch-wo-build server


electron-dev: build electron-prep
@make -j watch-wo-build electron-dev-server
doc-tests:
@echo "> Running documentation tests"
@( cd src && \
find . -name "*.elm" -print0 | \
xargs -0 -n 1 sh -c 'elm-proofread -- $0 || exit 255; echo "\n\n"'
)


install:
@echo "> Downloading dependencies"
@mkdir -p $(VENDOR_DIR)
@curl https://unpkg.com/lunr@2.3.6/lunr.js -o $(VENDOR_DIR)/lunr.js
@curl https://unpkg.com/remotestoragejs@1.2.2/release/remotestorage.js -o $(VENDOR_DIR)/remotestorage.min.js
@curl https://unpkg.com/fast-text-encoding@1.0.0/text.min.js -o $(VENDOR_DIR)/text-encoding-polyfill.min.js
@curl https://unpkg.com/tachyons@4.11.1/css/tachyons.min.css -o $(VENDOR_DIR)/tachyons.min.css
@curl https://unpkg.com/tocca@2.0.4/Tocca.min.js -o $(VENDOR_DIR)/tocca.min.js

@# Non-NPM dependencies
@curl https://gist.githubusercontent.com/icidasset/a888e02d7441aeb2af99263a3add0f73/raw/e4ca77c02e91a29e0c3c749d2ba80983a137a7aa/blockstack.min.js -o $(VENDOR_DIR)/blockstack.min.js
@curl https://raw.githubusercontent.com/icidasset/diffuse-musicmetadata/0ae8c854e18b6960b9f7e94b7eb47868416dc2ad/dist/musicmetadata.min.js -o $(VENDOR_DIR)/musicmetadata.min.js
@curl https://raw.githubusercontent.com/mpizenberg/elm-pep/071616d75ca61e261fdefc7b55bc46c34e44ea22/elm-pep.js -o $(VENDOR_DIR)/pep.js
@curl https://raw.githubusercontent.com/dmihal/Subworkers/6c3a57953615b26cd82fd39894b947f2b954fcfd/subworkers.js -o $(VENDOR_DIR)/subworkers-polyfill.js

electron-dev-server:
@ENV=DEV $(NODE_BIN)/electron $(BUILD_DIR)/electron/index.js
@# Minify non-minified dependencies
@echo "> Minifying dependencies"
@closure-compiler --js=$(VENDOR_DIR)/subworkers-polyfill.js --js_output_file=$(VENDOR_DIR)/subworkers-polyfill.min.js
@closure-compiler --js=$(VENDOR_DIR)/lunr.js --js_output_file=$(VENDOR_DIR)/lunr.min.js
@closure-compiler --js=$(VENDOR_DIR)/pep.js --js_output_file=$(VENDOR_DIR)/pep.min.js
@rm $(VENDOR_DIR)/subworkers-polyfill.js
@rm $(VENDOR_DIR)/lunr.js
@rm $(VENDOR_DIR)/pep.js


server:
@echo "> Booting up web server on port 5000"
@stack build && stack exec server
@devd --port 5000 --all --crossdomain --quiet --notfound=301.html $(BUILD_DIR)


test:
@echo "> Run tests"
@$(NODE_BIN)/elm-doctest \
src/App/Sources/Crypto/Hex.elm \
src/App/Sources/Crypto/Hmac.elm \
src/App/Sources/Services/Azure/Authorization.elm
@make -j doc-tests


watch: build
Expand All @@ -103,10 +115,8 @@ watch-wo-build:

watch-elm:
@watchexec -p \
-w $(SRC_DIR)/App \
-w $(SRC_DIR)/Lib \
-w $(SRC_DIR)/Slave \
-w $(SRC_DIR)/Styles \
-w $(SRC_DIR)/Applications \
-w $(SRC_DIR)/Library \
-- make elm


Expand Down
98 changes: 45 additions & 53 deletions README.md
@@ -1,93 +1,85 @@
<strong><img src="https://diffuse.sh/images/diffuse-dark.svg" alt="Diffuse" width="158" /></strong>

A music player which connects to your cloud/distributed storage.

<br />
<img src="https://icidasset-public.s3.amazonaws.com/diffuse.jpg" />

📍 Available at [https://diffuse.sh/](https://diffuse.sh/)
<img src="https://diffuse.sh/images/diffuse-dark.svg" alt="Diffuse" width="158" />

_A music player that connects to your cloud/distributed storage,
in the form of a static, serverless, web application._

📍 Available at [diffuse.sh](https://diffuse.sh/) and for [download](https://github.com/icidasset/diffuse/releases).

## Versions

🌍 [Web](https://diffuse.sh/)
Chrome, Firefox, Safari & Edge.

🖥 [Native](https://github.com/icidasset/diffuse/releases)
MacOS, Linux & Windows.
<small>Unique features: Add music from local filesystem, WebDAV & media-keys support.</small>
<br />
<img src="https://icidasset-public.s3.amazonaws.com/diffuse-v2-alpha.jpg" />



## Integrations
### Integrations

[More info](https://diffuse.sh/about/)
User layer for user-data storage.
Music layer for music storage.

#### User layer

- [Blockstack](https://blockstack.org/)
- [RemoteStorage](remotestorage.io)
- [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) <small>(ie. anonymous mode)</small>
- [~~Blockstack~~](https://blockstack.org/) <small>(TODO)</small>
- [Dropbox](https://www.dropbox.com/)
- [IndexedDB](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API) <small>(browser)</small>
- [IPFS](https://ipfs.io/)
- [RemoteStorage](https://remotestorage.io/)
- [Textile](https://github.com/textileio/go-textile)

#### Music layer

- [Amazon S3](https://aws.amazon.com/s3/)
- [Azure Blob Storage](https://azure.microsoft.com/en-us/services/storage/blobs/)
- [Azure File Storage](https://azure.microsoft.com/en-us/services/storage/files/)
- [~~Blockstack Gaia Storage~~](https://github.com/blockstack/gaia) <small>(TODO)</small>
- [Dropbox](https://dropbox.com/)
- [Google Drive](https://drive.google.com/)
- [IPFS](https://ipfs.io/)
- Local Filesystem <small>(native only)</small>
- [WebDAV](https://en.wikipedia.org/wiki/WebDAV) <small>(native only)</small>
- [WebDAV](https://en.wikipedia.org/wiki/WebDAV)



## Q&A
---


__Why don't you support WebDAV on the web version?__
Most WebDAV servers aren't built according to the [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) specification.
Which is a must-have for the web version, otherwise it doesn't work.
The WebDAV version was built with [NextCloud](https://nextcloud.com/) in mind.

### Hosting on your own server

Diffuse is a static web application, which means it's just HTML, CSS and Javascript. No REST API, database, or anything backend-related involved. The app uses a hash, aka. fragment, based routing system, so you don't need any special server rules for routing. You can download a pre-build web-only version of Diffuse on the [releases](https://github.com/icidasset/diffuse/releases) page. Diffuse uses service workers, so you may need HTTPS for it to work smoothly in certain browsers. I should also note that some source services use OAuth, so you'll need to use your own application credentials (eg. google drive client id + secret).

## Dependencies
In short:
- Diffuse is a static, serverless, web application
- Routing is done using hashes/fragments (eg. `diffuse.sh/#/sources`)
- Download a web build on the [releases](https://github.com/icidasset/diffuse/releases) page
- Uses service workers (use HTTPS if possible)
- May need own OAuth application credentials for some source services

- Loads of `Elm`
- A moderate amount of `Haskell` for the build system and static server
- A tiny bit of `Node` (browserify vendor js & doc tests)


---

## Development

```shell
# This assumes that you are using macOS

brew install haskell-stack
brew install elm
brew install nodejs
brew install watchexec
### Building it yourself

npm install
stack setup
For version numbers, see `.tool-versions` and `stack.yaml`.
All of these, except the last one, can be install using [homebrew](https://brew.sh/).

# Other dependencies
# 1. For building the Electron version
brew install makeicns
brew install imagemagick
```
- [Elm](https://elm-lang.org/) programming language
- [Haskell](https://docs.haskellstack.org/en/stable/README/) programming language
- [Google Closure Compiler](https://github.com/google/closure-compiler#getting-started) minifying assets
- [Devd](https://github.com/cortesi/devd) web server for development (optional)
- [Watchexec](https://github.com/watchexec/watchexec) watching for file changes (optional)
- [Elm Proofread](https://github.com/icidasset/elm-proofread) documentation tests (optional)

### How to run

```shell
# build + server + watch
make
# 🍱

# 1. Install programming languages:
# Elm 0.19 & Haskell (Stack), see links above

# make a static `./build`
make build
# 2. Install vendor dependencies
make install

# run tests
make test
# 3. Build, start server & watch for changes
make
```
11 changes: 0 additions & 11 deletions electron/builder.yaml

This file was deleted.

0 comments on commit c24c0bf

Please sign in to comment.