diff --git a/Picture_Puzzle_web.db b/Picture_Puzzle_web.db new file mode 100644 index 0000000..d325e48 Binary files /dev/null and b/Picture_Puzzle_web.db differ diff --git a/instance/Picture_Puzzle_web.db b/instance/Picture_Puzzle_web.db index 61ec0da..cded6c0 100644 Binary files a/instance/Picture_Puzzle_web.db and b/instance/Picture_Puzzle_web.db differ diff --git a/main.py b/main.py index 0580b5e..f9a7fd0 100644 --- a/main.py +++ b/main.py @@ -17,7 +17,7 @@ app = Flask(__name__) app.secret_key = 'bebra' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///Picture_Puzzle_web.db' app.config['UPLOAD_FOLDER'] = 'uploads' -app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif', 'mp4', 'waw'} +app.config['ALLOWED_EXTENSIONS'] = {'png', 'jpg', 'jpeg', 'gif', 'mp4', 'waw', 'pdf'} db = SQLAlchemy(app) logging.basicConfig(level=logging.DEBUG) class User(db.Model): @@ -58,11 +58,10 @@ class ForumComment(db.Model): post_id = db.Column(db.Integer, db.ForeignKey('forumpost.id'), nullable=False) created_by = db.Column(db.String(100), nullable=False) creation_date = db.Column(db.DateTime, nullable=False) - media = db.Column(db.Integer) # Assuming 'media' is a column containing media IDs + media = db.Column(db.Integer) text = db.Column(db.Text, nullable=False) edited = db.Column(db.Boolean, default=False) - # Define a primaryjoin expression post = relationship("ForumPost", primaryjoin="foreign(ForumComment.post_id) == remote(ForumPost.id)") class Media(db.Model): @@ -78,6 +77,7 @@ class CreatePostForm(FlaskForm): text = TextAreaField('Post Content', validators=[InputRequired()]) media = FileField('Insert Media', validators=[FileAllowed(app.config['ALLOWED_EXTENSIONS'])]) + def admin_login_required(view_func): @wraps(view_func) def decorated_function(*args, **kwargs): @@ -238,14 +238,12 @@ def category(category_name): def create_post(category_id): form = CreatePostForm() category = ForumCategory.query.get_or_404(category_id) - - # Provide choices for category_id field + form.category_id.choices = [(category.id, category.category_name) for category in ForumCategory.query.all()] - if form.validate_on_submit(): - post_name = form.post_name.data - created_by = form.created_by.data - text = form.text.data + if request.method == 'POST': + post_name = request.form['post_name'] + text = request.form['text'] media_files = request.files.getlist('media') media_filenames = [] @@ -254,11 +252,15 @@ def create_post(category_id): filename = secure_filename(file.filename) # type: ignore file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) media_filenames.append(filename) + + user_nickname = None + if g.user: + user_nickname = g.user.username new_post = ForumPost( category_id=category_id, post_name=post_name, - created_by=created_by, + created_by=user_nickname, text=text, creation_date=datetime.now(), edited=False @@ -272,10 +274,11 @@ def create_post(category_id): db.session.commit() - return redirect(url_for('category', category_id=category_id)) - + return redirect(url_for('category', category_name=category.category_name.lower())) + return render_template('create_post.html', form=form, category=category) + @app.route('/forums/', methods=['GET', 'POST']) def view_post(post_id): post = ForumPost.query.get_or_404(post_id) diff --git a/templates/category.html b/templates/category.html index f37d046..f5de4d8 100644 --- a/templates/category.html +++ b/templates/category.html @@ -12,7 +12,7 @@
{% for post in posts %} - +
{{ post.post_name }}

{{ post.text }}

Created by {{ post.created_by }} - {{ post.creation_date }} diff --git a/templates/create_post.html b/templates/create_post.html index a9d35b9..32142cb 100644 --- a/templates/create_post.html +++ b/templates/create_post.html @@ -81,7 +81,8 @@

Create a New Post

-
+ + {{ form.csrf_token }}
@@ -95,6 +96,7 @@
    +

    Note: **bold** for bold text, *italic* for italic text

    diff --git a/templates/design-and-music.html b/templates/design-and-music.html index 5a37565..4a49fe7 100644 --- a/templates/design-and-music.html +++ b/templates/design-and-music.html @@ -9,6 +9,8 @@

    Design and music making

    ruDALL-E generated image -


    Design and music making process was sometimes interesting or quick and other times quite time-consuming.

    +


    Design and music making process was sometimes interesting or quick and other times quite time-consuming. Many of the early design choices were scrapped completely, while some parts were remade to be more suitable for the game’s style.

    + While the original Picture Puzzle widget was semi-realistic to match the overall Windows app style, the idea for the remake’s design choice came mostly from the goal to make the game work faster and smoother, as well as the fact that pixel sprites are often easier to animate and take up much less space than HD sprites. +

    {% endblock %} diff --git a/templates/history.html b/templates/history.html index 07a1ff8..dca7258 100644 --- a/templates/history.html +++ b/templates/history.html @@ -9,6 +9,8 @@

    Picture Puzzle history

    Picture Puzzle original -


    The widgets originated in the Sideshow project at Microsoft Research. Its development started in the summer of 2000 and lasted for 1 year under the Microsoft brand.

    +


    The widgets originated in the Sideshow project at Microsoft Research. Its development started in the summer of 2000 and lasted for 1 year under the Microsoft brand. In 2001, Picture Puzzle was released for Windows Vista, and then later was included in Windows 7 upon its release. Just like all the other gadgets, Picture Puzzle was quite popular as a form of a fun and interactive way for users to enjoy their favorite images while challenging their puzzle-solving skills.

    Sadly, rumors started to spread about the malicious potential gadgets had, as most gadgets were created by third-party developers, which could result in malware being coded into the gadgets. Because of that, shortly after Windows 7 release Microsoft had officially announced the removal of gadgets.


    + womp womp +

    {% endblock %}