Skip to content

Commit

Permalink
+ upload site WIP
Browse files Browse the repository at this point in the history
* changing CSS file organization
  • Loading branch information
lunden23 committed Jan 24, 2022
1 parent 7ae8b13 commit 68bc81e
Show file tree
Hide file tree
Showing 18 changed files with 503 additions and 227 deletions.
6 changes: 6 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/skyflask.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/sqldialects.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class Config(object):
SECRET_KEY = "cloaked"
SQLALCHEMY_DATABASE_URI = "sqlite:///site.db"
SQLALCHEMY_TRACK_MODIFICATIONS = False
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


if __name__ == '__main__':
app.run()
app.run(debug=True)
3 changes: 2 additions & 1 deletion skanhama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
app = Flask(__name__)
app.config["SECRET_KEY"] = "cloaked"
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///site.db"
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
db = SQLAlchemy(app)
login_manager = LoginManager(app)
login_manager.login_view = "login"
login_manager.login_message_category = "flash flash-fail"

from skanhama import routes
from skanhama import routes, models
2 changes: 1 addition & 1 deletion skanhama/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
class RegistrationForm(FlaskForm):
username = StringField("Username", validators=[DataRequired(), Length(min=4, max=23)])
email = StringField("Email", validators=[DataRequired(), Email(), Length(min=4, max=120)])
confirm_email = StringField("Confirm Email", validators=[DataRequired(), Email(), Length(min=4, max=120), EqualTo("email")])
password = PasswordField("Password", validators=[DataRequired()])
confirm_password = PasswordField("Confirm Password", validators=[DataRequired(), EqualTo("password")])
submit = SubmitField("Sign Up")
Expand Down Expand Up @@ -60,6 +59,7 @@ class UploadPackage(FlaskForm):
name = StringField("Package Name", validators=[DataRequired()])
version = StringField("Current Version", validators=[DataRequired(), Length(min=1, max=30)])
author = StringField("Author(s) or Team", validators=[DataRequired()])
summary = TextAreaField("Brief Description", validators=[DataRequired(), Length(min=1, max=240)])
description = TextAreaField("Description", validators=[DataRequired(), Length(min=1, max=5000)])
requirements = TextAreaField("Requirements", validators=[DataRequired()])
category = SelectField("Primary Category", choices=["Combat", "Sex"], validators=[DataRequired()])
Expand Down
4 changes: 3 additions & 1 deletion skanhama/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class User(db.Model, UserMixin):
confirmed = db.Column(db.Boolean, nullable=False, default=False)
confirmed_on = db.Column(db.DateTime, nullable=True)
admin = db.Column(db.Boolean, nullable=False, default=False)
uploads = db.relationship("Package", backref="upload_author", lazy=True)
uploads = db.relationship("Package", backref="upload_author", lazy="dynamic")
comments = db.relationship("Comment", backref="comment_author", lazy=True)

def __repr__(self):
Expand All @@ -29,12 +29,14 @@ class Package(db.Model):
name = db.Column(db.String(120), unique=True, nullable=False)
version = db.Column(db.String(30), nullable=False)
author = db.Column(db.String(100), nullable=False)
summary = db.Column(db.String(230), nullable=False)
description = db.Column(db.Text, nullable=False)
requirements = db.Column(db.Text, nullable=False)
package_dir = db.Column(db.String(400), nullable=False, unique=True)
date_uploaded = db.Column(db.DateTime, nullable=False, default=datetime.utcnow)
downloads_total = db.Column(db.BigInteger, nullable=False)
downloads_current_version = db.Column(db.BigInteger, nullable=False)
likes = db.Column(db.BigInteger, nullable=False)
views_total = db.Column(db.BigInteger, nullable=False)
nsfw = db.Column(db.Boolean, nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
Expand Down
36 changes: 34 additions & 2 deletions skanhama/routes.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import secrets
import os.path
import sqlite3
import zipfile
import hashlib
import shutil
import json

from datetime import datetime
from pathlib import Path
from flask import render_template, url_for, flash, redirect, request
from flask import render_template, url_for, flash, redirect, request, jsonify
from flask_login import login_user, current_user, logout_user, login_required
from werkzeug.security import generate_password_hash, check_password_hash
from skanhama import app, db
Expand Down Expand Up @@ -178,18 +179,20 @@ def upload():
pack = Package(name=form.name.data,
version=form.version.data,
author=current_user.username,
summary=form.summary.data,
description=form.description.data,
requirements=form.requirements.data,
package_dir=file_dict["_package_data"][1],
date_uploaded=datetime.now(),
downloads_total=0,
downloads_current_version=0,
views_total=0,
likes=0,
nsfw=form.nsfw.data,
user_id=current_user.id)
db.session.add(pack)
db.session.commit()
flash("Your package has been successfully uploaded.", "success")
flash("Your package was successfully uploaded.", "success")
else:
flash("Your package did not contain any .hkx files and has not been uploaded. Please ensure you "
"upload a package that contains valid Skyrim animation files.", "fail")
Expand All @@ -211,3 +214,32 @@ def about():
@app.route("/faq")
def faq():
return render_template("faq.html")


# @app.route("/livesearch", methods=["GET", "POST"])
# def livesearch():
# # searchbox = request.form.get("text")
# # con = sqlite3.connect("site.db")
# # cursor = con.cursor()
# # query = "select name from package where name LIKE '{}%' order by name".format(searchbox)
# # cursor.execute(query)
# # result = cursor.fetchall()
# # return jsonify(result)
# searchbox = request.form.get("text")
# searchbox = '%' + searchbox + '%'
# engine = create_engine('sqlite:///site.db', echo=True)
# conn = engine.connect()
# result = conn.engine.execute("select * from PACKAGE where name LIKE ? order by name LIMIT 4", searchbox).fetchall()
# conn.close()
# result= Convert(result)
# return result
#
#
# def Convert(lst):
# resultproxy = lst
# d, a = {}, []
# for rowproxy in resultproxy:
# for column, value in rowproxy.items():
# d = {**d, **{column: value}}
# a.append(d)
# return d
Binary file modified skanhama/site.db
Binary file not shown.
Binary file removed skanhama/static/bg_01 copy.jpg
Binary file not shown.
66 changes: 49 additions & 17 deletions skanhama/static/scripts.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,40 @@
// Function to handle search bar in the navigation bar
// Expands on click to cover other nav bar items
function navSearchFocus() {
let nav = document.getElementById("nav-list");
nav.style.display = "none";
}
// Handle opening and closing of the navbar search input
// Opens on search icon click and closes when user presses outside the search input
const navSearchIcon = document.getElementById("nav-search-icon");
const navSearchInput = document.getElementById("nav-search-input");
const navBar = document.getElementById("nav-list");

window.onclick = function(event) {
if (!event.target.matches(".search-nav")) {
let nav = document.getElementById("nav-list");
nav.style.display = "visible";
}
navSearchIcon.addEventListener("click", navSearchFunction);
function navSearchFunction() {
navSearchIcon.style.display = "none";
navBar.style.display = "none";
navSearchInput.style.display = "inline-flex";
navSearchInput.focus();
window.addEventListener("click", navSearchClickOut);
}

// Function to handle dropdown of account menu when user is logged in
// Dropdown is shown on button click and hidden on button click or click outside of dropdown area
function dropdownAccount() {
document.getElementById("dropdownAccount").classList.toggle("dropdown-show")
const navSearchClickOut = (e) => {
if (!e.target.id.includes("nav-search-input") && !e.target.id.includes("nav-search-icon")) {
navSearchInput.style.display = "none";
navSearchIcon.style.display = "block";
navBar.style.display = "inline-flex";
window.removeEventListener("click", navSearchClickOut);
}
};

// Handle opening and closing of the Account Menu
// Opens on Account icon click and closes when user presses outside the menu
const accountMenuIcon = document.getElementById("accountMenuIcon");
const accountMenu = document.getElementById("dropdownAccount");

accountMenuIcon.addEventListener("click", accountMenuFunction);
function accountMenuFunction() {
accountMenu.classList.toggle("dropdown-show");
window.addEventListener("click", accountMenuClickOut);
}

window.onclick = function(event) {
if (!event.target.matches(".btn-dropdown")) {
const accountMenuClickOut = (e) => {
if (!e.target.matches(".btn-dropdown")) {
const dropdowns = document.getElementsByClassName("dropdown-content");
let i;
for (i = 0; i < dropdowns.length; i++) {
Expand All @@ -28,5 +43,22 @@ window.onclick = function(event) {
openDropdown.classList.remove("dropdown-show");
}
}
window.removeEventListener("click", accountMenuClickOut);
}
}

// Live (Active) Search function in the search bar in the nav menu
// $(function (){
// $("#nav-search-input").on("input", function(e){
// let textFrontEnd = $("#nav-search-input").val();
// // console.log(textFrontEnd);
// $.ajax({
// method:"post",
// url:"/livesearch",
// data:{text:textFrontEnd},
// success:function (res){
// console.log(res);
// }
// })
// })
// })
Loading

0 comments on commit 68bc81e

Please sign in to comment.