Skip to content

Commit

Permalink
🔀: merge #6 from frissyn/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
frissyn authored Nov 2, 2021
2 parents b53bbec + 37be5d9 commit acb87d5
Show file tree
Hide file tree
Showing 51 changed files with 1,079 additions and 812 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "CodeQL"

on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '0 14 * * 3'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
language: ['python']
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2

- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v1

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
31 changes: 31 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Python package

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=90 --statistics
37 changes: 14 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
main.py
__pycache__/
*.py[cod]
*$py.class
.Python
build/
develop-eggs/
# PYTHON FILES
# ------------
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
build/
*.egg.info/
__pycache__/
_*/

# ENVIRON FILES
# ------------
main.py
.env
.replit
env/
.lock
.toml
venv/
node_modules/
package-lock.json
100 changes: 0 additions & 100 deletions COLORS.md

This file was deleted.

4 changes: 2 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 IreTheKID
Copyright (c) 2021 frissyn

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
50 changes: 18 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,34 @@
# Reflux: A Replit.com IDE Theming Tool [![Run on Replit.com](https://replit.com/badge/github/frissyn/Reflux)](https://replit.com/github/frissyn/Reflux)
# Reflux <img src="https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square"> <a href="https://github.com/frissyn/Reflux/releases"><img src="https://img.shields.io/github/release/frissyn/Reflux.svg?style=flat-square"></a> <img src="https://img.shields.io/uptimerobot/ratio/m789613888-63da553f1a743d8870946ed3?style=flat-square">

Reflux is a tool to create and modify the default styles that apply to your IDE on [Replit.com](https://replit.com/). Using Python, you can create themes, set colors, and generate easy-to-use JavaScript Bookmarlets for use in any Repl. Designed so that those who are unfamiliar with Python can still create themes!
Reflux is a third-party tool for creating and publishing site-wide style themes to Replit! Using Reflux, users can easily change Replit's default CSS variables, and share thier created themes with other users via the [marketplace](https://market.reflux.repl.co/). Find the quickstart example [here](https://replit.com/@reflux/template). Fork it and follow the guide to get started using Reflux and creating themes on Replit!

**Recent Update: `v0.2.0`:**
Reflux themes will now work outside of the IDE more consistently. Rebuild your themes to reflect these changes!
### Showcase

# Overview
![image](https://storage.googleapis.com/replit/images/1635881358588_fb0b7e55745d4ffcdfce7ec2f5c33fd7.png)

![image](https://storage.googleapis.com/replit/images/1635881352143_96390d7d5b4809e8ef1f83a9e2bf8355.png)

### Installation

|Manager |Command |
|:----------------|:---------------------------------------------|
|**pip** |`pip install reflux` |
|**poetry** |`python -m poetry add reflux` |
|**Replit.com** |Search `reflux` in the package tab and add it.|

### Quickstart

```python
import reflux

t = reflux.Theme({
"name": "New Theme",
"author": "Your Username",
"description": "A simple theme to get started with!",
"default": "light"
})

t.set_color("primary-1", "whitesmoke")
|**replit** |Search `reflux` in the Packages tab and `+` it|

t.set_colors({
"primary-2": "rbga(255, 255, 255, 0.48)",
"primary-3": "hsl(0, 100%, 50%)"
})
### Documentation

t.build("mytheme.min.js")
```
Find extensive documentation on Reflux and it uses [here](https://github.com/frissyn/Reflux/tree/master/docs).

Then copy the resulting JS code into a bookmarklet in your broswer, and run it in your Repl! (Running it again will prompt you for an option to turn it off). Try it out with one of the premade themes [here](https://github.com/frissyn/Reflux/tree/master/themes)! Images of these themes are in their respective folders.
### Contributing

You can find a complete tutorial on Reflux themes [here](https://replit.com/talk/x/x/118029)!
1. Fork the repository: [`Fork`](https://github.com/frissyn/Reflux/fork)
2. Clone locally (`git clone https://github.com/<username>/Reflux.git`)
3. Create your feature branch (`git checkout -b my-new-feature`)
4. Commit your changes (`git commit -a -m 'Add some feature'`)
5. Push to the branch (`git push origin my-new-feature`)
6. Create a new Pull Request! 🎉

### Examples
**Local Developement:**

![iris](https://storage.googleapis.com/replit/images/1611845083584_d6428aecacbdab9478764c700f76a665.png)
![candyland](https://storage.googleapis.com/replit/images/1611845281908_6869f49b3d2a3722fbb766c96aeae0cc.png)
![blueberry](https://storage.googleapis.com/replit/images/1611845384713_7d7bc415e3615439edbcd1fce6576054.png)
In order to properly test the Reflux package locally run `bash bin/local` in the project directory. `bash bin/clean` will delete the tarball and build directories.
30 changes: 30 additions & 0 deletions api/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
import flask
import secrets
import repltalk
import psycopg2

from flask_migrate import Migrate
from flask_sqlalchemy import SQLAlchemy

app = flask.Flask(__name__)
replit = repltalk.Client()
app.config.from_mapping({
"DEBUG": False,
"TESTING": False,
"FLASK_DEBUG": 0,
"CACHE_TYPE": "simple",
"CACHE_DEFAULT_TIMEOUT": 300,
"SECRET_KEY": secrets.token_hex(16),
"SQLALCHEMY_DATABASE_URI": os.environ["DATABASE_URL"],
"SQLALCHEMY_TRACK_MODIFICATIONS": False
})

conn = psycopg2.connect(os.environ["DATABASE_URL"], sslmode="require")


tokens = [os.getenv("TOKEN")]
db = SQLAlchemy(app)
migrator = Migrate(app, db)

from .routes import *
62 changes: 62 additions & 0 deletions api/app/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
from app import db

from datetime import datetime as dt

from sqlalchemy.inspection import inspect


class User(db.Model):
id = db.Column(db.Integer, primary_key=True)
avatar = db.Column(db.String, nullable=False)
name = db.Column(db.String(64), nullable=False)
description = db.Column(db.String, nullable=False)
publish_key = db.Column(db.String(32), nullable=False, unique=True)
admin = db.Column(db.Boolean, nullable=False, default=False)
timestamp = db.Column(db.DateTime, default=dt.utcnow(), nullable=False)
themes = db.relationship(
"Theme", lazy=True, backref=db.backref("author", lazy=True)
)

def cereal(self, admin=False):
result = {c: getattr(self, c) for c in inspect(self).attrs.keys()}
result["themes"] = [t.cereal(partial=True) for t in result["themes"]]

if not admin:
result.pop("admin")
result.pop("publish_key")

return result

def __repr__(self):
return f"<User @id:{self.id}, @name:{self.name}>"


class Theme(db.Model):
id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String, nullable=False)
stylesheet = db.Column(db.Text, nullable=False)
referral = db.Column(db.String(16), nullable=False, unique=True)
downloads = db.Column(db.Integer, nullable=False, default=0)
description = db.Column(db.String, nullable=False, default="")
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))

def cereal(self, admin=False, partial=False):
result = {c: getattr(self, c) for c in inspect(self).attrs.keys()}

if partial:
result.pop("author")
else:
a = self.author
author = {c.name: getattr(a, c.name) for c in a.__table__.columns}

result["author"] = author
result.pop("author_id")

if not admin:
result["author"].pop("admin")
result["author"].pop("publish_key")

return result

def __repr__(self):
return f"<Theme @author:{self.author} @referral:{self.referral}>"
Loading

0 comments on commit acb87d5

Please sign in to comment.