Skip to content

Commit

Permalink
Merge pull request #246 from Bubobubobubobubo/sardine-web-plugin
Browse files Browse the repository at this point in the history
Sardine web plugin
  • Loading branch information
Bubobubobubobubo authored Jul 18, 2023
2 parents 826a1e8 + e1fcca8 commit e9e1434
Show file tree
Hide file tree
Showing 72 changed files with 51 additions and 12,184 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,3 @@ poetry.lock
.vim
.vscode
.idea

# Svelte
!sardine/client/src/lib
3 changes: 0 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
prune **/.svelte-kit
prune **/__pycache__
prune **/build
prune **/node_modules
Binary file modified docs/sardine_doc/src/baby_steps.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 23 additions & 32 deletions docs/sardine_doc/src/editors/fishery.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,26 @@

![img](fishery_web.png)

You don't need a text editor to play with **Sardine**.
Just start **Sardine** with its own text editor by typing
`sardine web`. You can optionally the `--port` and `--host`
arguments for fine-tuning your local server:

sardine web
sardine web --port 12345
sardine web --host 0.0.0.0 --port 8000

Your web browser will open as a result of typing the command.
Our text editor is a web application living in your web browser,
generally at `https://localhost:8000`. The text editor is simple
but has a few nice features:

- multi-pane / multi-buffer editing.
- access to the Sardine documentation.
- normal editing mode or [Vim](https://en.wikipedia.org/wiki/Vim_(text_editor)) mode.
- quick access to play/pause, etc.
- console for logging.
- **Shift + enter** to eval code
- **note:** you need to select code before running it)

The text editor also handles its own set of text files automatically.
You can retrieve them inside the **Sardine** folder (see the appropriate section).

## Building the web application yourself

For now, the application must be built manually in able to be used. In the `/sardine/client` directory,
run `yarn install` and `yarn run build` to build the text editor. As you might guess, you need to
install [Yarn](https://yarnpkg.com/) and also [npm](https://www.npmjs.com/). These are tools used by
Javascript developers to build their applications. These commands should only be runned once everytime
you install **Sardine**.

Sardine also comes with its own text editor named **Sardine Web**. If you have it installed on your computer, you will be able to start it simply by typing `sardine web` in your terminal!

Typing the command will automatically open your web browser on the editor page. Our text editor is a web application living in your browser. All your code files will also be stored on your web browser!

## Installation

1) Install [NodeJS](https://nodejs.org/en) for your OS/platform.
2) Install [Yarn](https://classic.yarnpkg.com/lang/en/docs/install/#mac-stable), a package manager for NodeJS.
3) With **NodeJS** and **Yarn** installed as per the guide, you can then install this package:

```bash
# From remote:
pip install git+https://github.com/sardine-system/sardine-web
# Or from local clone in current working directory:
pip install -e .[dev]
```

4) Type `sardine web` in your terminal and enjoy.

## Instructions

Everything you need to learn how to use the editor is already included. You will also find many **Sardine** tutorials directly included with the editor.
Binary file modified docs/sardine_doc/src/editors/fishery_web.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion docs/sardine_doc/src/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@

![img](baby_steps.png)

This section is covering the absolute basics of Sardine usage.
13 changes: 2 additions & 11 deletions docs/sardine_doc/src/installation/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ used by the application. You will also have to install some tools that will allo
- Press **Shift + Enter** and wait for the installation to be done! Close **SuperCollider** when done.
- **Optional:** You can also install [sc3plugins](https://github.com/supercollider/sc3-plugins) to get more audio effects and synthesizers!

3) Install [NodeJS](https://nodejs.org/en) and [Yarn](https://yarnpkg.com/) to build the integrated web editor.
- If you are installing the package from GitHub, the build process for the text editor will start automatically.

## Installing Sardine

We will now proceed to the installation of Sardine. Sardine is a Python library which is composed of two modules:
Expand All @@ -37,17 +34,11 @@ We will now proceed to the installation of Sardine. Sardine is a Python library
Install the development version (**recommanded**).
```python
git clone https://github.com/Bubobubobubobubo/sardine
cd sardine && python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable .
cd sardine && python -m pip install .
```
- **Optional**: You can install the outdated [Pypi package](https://pypi.org/project/sardine-system/) but it is older and lagging behind:
```python
python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable sardine-system
```

**Note**: the `--editable` flag is optional. You can remove it if you are not planning to modify **Sardine**!

- If you get an error when trying to install `python-rtmidi` because of `#include "longintrepr.h"`, you can try one of the following install commands:
**Note 2:** If you get an error when trying to install `python-rtmidi`, you can get it from these sources:
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi`
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git#eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba`

**Note**: the `python-rtmidi` project is now undergoing a maintainer transition. The situation should resolve quite soon! :)
13 changes: 2 additions & 11 deletions docs/sardine_doc/src/installation/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ used by the application. You will also have to install some tools that will allo
- You might have to add `sclang` to your path. To do so, copy `alias sclang="/Applications/SuperCollider.app/Contents/MacOS/sclang"`
into your `.bashrc` or `.zshrc` in the `$HOME` directory.

3) Install [NodeJS](https://nodejs.org/en) and [Yarn](https://yarnpkg.com/) to build the integrated web editor.
- If you are installing the package from GitHub, the build process for the text editor will start automatically.

## Installing Sardine

We will now proceed to the installation of Sardine. Sardine is a Python library which is composed of two modules:
Expand All @@ -39,17 +36,11 @@ We will now proceed to the installation of Sardine. Sardine is a Python library
Install the development version (**recommanded**).
```python
git clone https://github.com/Bubobubobubobubo/sardine
cd sardine && python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable .
cd sardine && python -m pip install --editable .
```
- **Optional**: You can install the outdated [Pypi package](https://pypi.org/project/sardine-system/) but it is older and lagging behind:
```python
python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable sardine-system
```

**Note**: the `--editable` flag is optional. You can remove it if you are not planning to modify **Sardine**!

- If you get an error when trying to install `python-rtmidi` because of `#include "longintrepr.h"`, you can try one of the following install commands:
**Note 2:** If you get an error when trying to install `python-rtmidi`, you can get it from these sources:
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi`
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git#eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba`

**Note**: the `python-rtmidi` project is now undergoing a maintainer transition. The situation should resolve quite soon! :)
6 changes: 4 additions & 2 deletions docs/sardine_doc/src/installation/post_install_checkup.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ The source of this error is currently unknown and is not Sardine related. Hopefu
## Can you run sardine and sardine web?

- in your terminal, run `sardine` first! If you see a splashscreen, everything is fine! :)
- in your terminal, run `sardine web`! Does your web browser magically open? You are good to go.
- Windows users: you will sometimes have to run this twice. Run the app. Quit it and launch again.

## Can you run sardine config?

Expand All @@ -43,3 +41,7 @@ The source of this error is currently unknown and is not Sardine related. Hopefu
[configuration](../configuration/configuration_tool.md) section. Head to the `SuperCollider`
section and turn everything on!

## You need a code editor now!

- Check out the Editor section to choose your favorite editor!

13 changes: 3 additions & 10 deletions docs/sardine_doc/src/installation/preliminary_words.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,17 @@ Now, **kill your command line** and restart a fresh terminal. The output of `pyt
Python 3.11.3
```

## 2) Installing some Web Tools

**Sardine** also requires you to install some tools needed for web development in order to install properly. This is because of **Sardine Web**, our very cool web editor that will be available once everything is ready.

- Install [NodeJS](https://nodejs.org/en/download): this is the base stack for web development in JavaScript.
- Once done, run the following command in your terminal: `npm install yarn -g`


## 3) Other versions of Sardine
## 2) Other versions of Sardine

- As funny as it may sound, I am not the owner of the `sardine` package on Pypi. **Sardine** is named `sardine-system`. Some people sometimes end up installing a totally unrelated tool!
- `sardine-system` is very outdated. Please install from source.

## 4) The modular architecture of Sardine
## 3) The modular architecture of Sardine

- Sardine is a **very** flexible software. It can be hard to install for that reason.
- You probably don't need everything but you need to understand the architecture:
- **Sardine web** is an optional text editor for **Sardine** written with JavaScript.
- **Sardine web** is an optional text editor for **Sardine** written in TypeScript.
- **Sardine** is an asynchronous Python interpreter firing up the **Sardine** library.
- **Sardine Core** is the Python library that is responsible for all that livecoding.
- it defines a temporal engine allowing you to live code in Python.
Expand Down
12 changes: 2 additions & 10 deletions docs/sardine_doc/src/installation/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ used by the application. You will also have to install some tools that will allo
- Press **Shift + Enter** and wait for the installation to be done! Close **SuperCollider** when done.
- **Optional:** You can also install [sc3plugins](https://github.com/supercollider/sc3-plugins) to get more audio effects and synthesizers!

3) Install [NodeJS](https://nodejs.org/en) and [Yarn](https://yarnpkg.com/) to build the integrated web editor.
- If you are installing the package from GitHub, the build process for the text editor will start automatically.

## Installing Sardine

Expand All @@ -40,17 +38,11 @@ We will now proceed to the installation of Sardine. Sardine is a Python library
Install the development version (**recommanded**).
```python
git clone https://github.com/Bubobubobubobubo/sardine
cd sardine && python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable .
cd sardine && python -m pip install --editable .
```
- **Optional**: You can install the outdated [Pypi package](https://pypi.org/project/sardine-system/) but it is older and lagging behind:
```python
python -m pip install --find-links https://thegamecracks.github.io/python-rtmidi-wheels/ --editable sardine-system
```

**Note**: the `--editable` flag is optional. You can remove it if you are not planning to modify **Sardine**!

- If you get an error when trying to install `python-rtmidi` because of `#include "longintrepr.h"`, you can try one of the following install commands:
**Note 2:** If you get an error when trying to install `python-rtmidi`, you can try to get it from these sources:
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git@eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba#egg=python-rtmidi`
- `python -m pip install git+https://github.com/SpotlightKid/python-rtmidi.git#eb16ab3268b29b94cd2baa6bfc777f5cf5f908ba`

**Note**: the `python-rtmidi` project is now undergoing a maintainer transition. The situation should resolve quite soon! :)
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ classifiers = [
dependencies = [
"ziffers>=0.0.1",
"parsimonious>=0.10.0",
"pygtail>=0.14.0",
"Flask-SocketIO>=5.3.2",
"Flask-Cors>=3.0",
"Flask>=2.2.2",
"Click>=8.1.3",
"LinkPython-extern>=1.0.2",
"python-rtmidi>=1.4.9",
Expand Down Expand Up @@ -94,7 +90,7 @@ Documentation = "https://sardine.raphaelforment.fr"
"Bug Tracker" = "https://github.com/Bubobubobubobubo/sardine/issues"

[project.scripts]
sardine = 'sardine.__main__:main'
sardine = 'sardine.__main__:run'

[tool.black]
target_version = ['py311']
Expand Down
59 changes: 14 additions & 45 deletions sardine/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from sardine.console import ConsoleManager
import click
import importlib.metadata
import os
import psutil
from typing import Tuple
Expand Down Expand Up @@ -64,50 +65,6 @@ def main(ctx: click.Context):
console.start()


# fishery web
# fishery web --host
# fishery web --port
# fishery web --host --port
# fishery config
@main.command(
short_help="Starts sardine as a web server",
help="""
This command starts sardine as a web server. The server can be accessed
at http://localhost:8000 by default.
""",
)
@click.option(
"-h",
"--host",
default="localhost",
help="The host to bind the server to.",
show_default=True,
type=str,
)
@click.option(
"-p",
"--port",
default=8000,
help="The port to bind the server to.",
show_default=True,
type=int,
)
@click.option(
"--no-browser",
is_flag=True,
help="Prevents the server from opening a browser window.",
)
def web(host: str, port: int, no_browser: bool):
from .server import WebServer

consoleManager = ConsoleManager()
server = WebServer(host=host, port=port)
server.start_in_thread(consoleManager.console)
if not no_browser:
server.open_in_browser()
consoleManager.start()


@main.command(
short_help="Starts sardine configuration tool",
help="This command starts Sardine configuration tool.",
Expand Down Expand Up @@ -141,5 +98,17 @@ def config_python():
edit_python_configuration()


if __name__ == "__main__":
def run_main_hooks() -> None:
entry_points = importlib.metadata.entry_points(group="sardine.cli_main_hooks")
for ep in entry_points:
hook = ep.load()
hook(main)


def run() -> None:
run_main_hooks()
main()


if __name__ == "__main__":
run()
Loading

0 comments on commit e9e1434

Please sign in to comment.