Skip to content

Commit acb87d5

Browse files
authored
🔀: merge #6 from frissyn/dev
2 parents b53bbec + 37be5d9 commit acb87d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1079
-812
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: "CodeQL"
2+
3+
on:
4+
push:
5+
branches: [master]
6+
pull_request:
7+
branches: [master]
8+
schedule:
9+
- cron: '0 14 * * 3'
10+
11+
jobs:
12+
analyze:
13+
name: Analyze
14+
runs-on: ubuntu-latest
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
language: ['python']
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v2
23+
with:
24+
fetch-depth: 2
25+
26+
- run: git checkout HEAD^2
27+
if: ${{ github.event_name == 'pull_request' }}
28+
29+
- name: Initialize CodeQL
30+
uses: github/codeql-action/init@v1
31+
with:
32+
languages: ${{ matrix.language }}
33+
34+
- name: Autobuild
35+
uses: github/codeql-action/autobuild@v1
36+
37+
- name: Perform CodeQL Analysis
38+
uses: github/codeql-action/analyze@v1
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Python package
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.7, 3.8, 3.9]
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Python ${{ matrix.python-version }}
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: ${{ matrix.python-version }}
23+
- name: Install dependencies
24+
run: |
25+
python3 -m pip install --upgrade pip
26+
pip install flake8 pytest
27+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
28+
- name: Lint with flake8
29+
run: |
30+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
31+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=90 --statistics

‎.gitignore

+14-23
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,17 @@
1-
main.py
2-
__pycache__/
3-
*.py[cod]
4-
*$py.class
5-
.Python
6-
build/
7-
develop-eggs/
1+
# PYTHON FILES
2+
# ------------
83
dist/
9-
downloads/
10-
eggs/
11-
.eggs/
12-
lib/
13-
lib64/
14-
parts/
15-
sdist/
16-
var/
17-
wheels/
18-
share/python-wheels/
19-
*.egg-info/
20-
.installed.cfg
21-
*.egg
22-
MANIFEST
4+
build/
5+
*.egg.info/
6+
__pycache__/
7+
_*/
8+
9+
# ENVIRON FILES
10+
# ------------
11+
main.py
2312
.env
13+
.replit
2414
env/
25-
.lock
26-
.toml
15+
venv/
16+
node_modules/
17+
package-lock.json

‎COLORS.md

-100
This file was deleted.

‎LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 IreTheKID
3+
Copyright (c) 2021 frissyn
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

‎README.md

+18-32
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,34 @@
1-
# Reflux: A Replit.com IDE Theming Tool [![Run on Replit.com](https://replit.com/badge/github/frissyn/Reflux)](https://replit.com/github/frissyn/Reflux)
1+
# 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">
22

3-
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!
3+
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!
44

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

8-
# Overview
7+
![image](https://storage.googleapis.com/replit/images/1635881358588_fb0b7e55745d4ffcdfce7ec2f5c33fd7.png)
8+
9+
![image](https://storage.googleapis.com/replit/images/1635881352143_96390d7d5b4809e8ef1f83a9e2bf8355.png)
910

1011
### Installation
1112

1213
|Manager |Command |
1314
|:----------------|:---------------------------------------------|
1415
|**pip** |`pip install reflux` |
1516
|**poetry** |`python -m poetry add reflux` |
16-
|**Replit.com** |Search `reflux` in the package tab and add it.|
17-
18-
### Quickstart
19-
20-
```python
21-
import reflux
22-
23-
t = reflux.Theme({
24-
"name": "New Theme",
25-
"author": "Your Username",
26-
"description": "A simple theme to get started with!",
27-
"default": "light"
28-
})
29-
30-
t.set_color("primary-1", "whitesmoke")
17+
|**replit** |Search `reflux` in the Packages tab and `+` it|
3118

32-
t.set_colors({
33-
"primary-2": "rbga(255, 255, 255, 0.48)",
34-
"primary-3": "hsl(0, 100%, 50%)"
35-
})
19+
### Documentation
3620

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

40-
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.
23+
### Contributing
4124

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

44-
### Examples
32+
**Local Developement:**
4533

46-
![iris](https://storage.googleapis.com/replit/images/1611845083584_d6428aecacbdab9478764c700f76a665.png)
47-
![candyland](https://storage.googleapis.com/replit/images/1611845281908_6869f49b3d2a3722fbb766c96aeae0cc.png)
48-
![blueberry](https://storage.googleapis.com/replit/images/1611845384713_7d7bc415e3615439edbcd1fce6576054.png)
34+
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.

‎api/app/__init__.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
import flask
3+
import secrets
4+
import repltalk
5+
import psycopg2
6+
7+
from flask_migrate import Migrate
8+
from flask_sqlalchemy import SQLAlchemy
9+
10+
app = flask.Flask(__name__)
11+
replit = repltalk.Client()
12+
app.config.from_mapping({
13+
"DEBUG": False,
14+
"TESTING": False,
15+
"FLASK_DEBUG": 0,
16+
"CACHE_TYPE": "simple",
17+
"CACHE_DEFAULT_TIMEOUT": 300,
18+
"SECRET_KEY": secrets.token_hex(16),
19+
"SQLALCHEMY_DATABASE_URI": os.environ["DATABASE_URL"],
20+
"SQLALCHEMY_TRACK_MODIFICATIONS": False
21+
})
22+
23+
conn = psycopg2.connect(os.environ["DATABASE_URL"], sslmode="require")
24+
25+
26+
tokens = [os.getenv("TOKEN")]
27+
db = SQLAlchemy(app)
28+
migrator = Migrate(app, db)
29+
30+
from .routes import *

‎api/app/models.py

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
from app import db
2+
3+
from datetime import datetime as dt
4+
5+
from sqlalchemy.inspection import inspect
6+
7+
8+
class User(db.Model):
9+
id = db.Column(db.Integer, primary_key=True)
10+
avatar = db.Column(db.String, nullable=False)
11+
name = db.Column(db.String(64), nullable=False)
12+
description = db.Column(db.String, nullable=False)
13+
publish_key = db.Column(db.String(32), nullable=False, unique=True)
14+
admin = db.Column(db.Boolean, nullable=False, default=False)
15+
timestamp = db.Column(db.DateTime, default=dt.utcnow(), nullable=False)
16+
themes = db.relationship(
17+
"Theme", lazy=True, backref=db.backref("author", lazy=True)
18+
)
19+
20+
def cereal(self, admin=False):
21+
result = {c: getattr(self, c) for c in inspect(self).attrs.keys()}
22+
result["themes"] = [t.cereal(partial=True) for t in result["themes"]]
23+
24+
if not admin:
25+
result.pop("admin")
26+
result.pop("publish_key")
27+
28+
return result
29+
30+
def __repr__(self):
31+
return f"<User @id:{self.id}, @name:{self.name}>"
32+
33+
34+
class Theme(db.Model):
35+
id = db.Column(db.Integer, primary_key=True)
36+
name = db.Column(db.String, nullable=False)
37+
stylesheet = db.Column(db.Text, nullable=False)
38+
referral = db.Column(db.String(16), nullable=False, unique=True)
39+
downloads = db.Column(db.Integer, nullable=False, default=0)
40+
description = db.Column(db.String, nullable=False, default="")
41+
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
42+
43+
def cereal(self, admin=False, partial=False):
44+
result = {c: getattr(self, c) for c in inspect(self).attrs.keys()}
45+
46+
if partial:
47+
result.pop("author")
48+
else:
49+
a = self.author
50+
author = {c.name: getattr(a, c.name) for c in a.__table__.columns}
51+
52+
result["author"] = author
53+
result.pop("author_id")
54+
55+
if not admin:
56+
result["author"].pop("admin")
57+
result["author"].pop("publish_key")
58+
59+
return result
60+
61+
def __repr__(self):
62+
return f"<Theme @author:{self.author} @referral:{self.referral}>"

0 commit comments

Comments
 (0)