-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,079 additions
and
812 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}>" |
Oops, something went wrong.