Skip to content

Conversation

@el-choco
Copy link

@el-choco el-choco commented Nov 6, 2025

change from softdelete to harddelete

change from softdelete to harddelete
currently only in German ( but can easily changed ) and open per URL https://your-domain.com/cleanup_posts.php
add smiles to post:
		$emoji_map = [
			':smile:'        => '😄',
			':laugh:'        => '😂',
			':wink:'         => '😉',
			':heart:'        => '❤️',
			':broken_heart:' => '💔',
			':fire:'         => '🔥',
			':star:'         => '⭐',
			':check:'        => '✅',
			':cross:'        => '❌',
			':thumbs_up:'    => '👍',
			':thumbs_down:'  => '👎',
			':clap:'         => '👏',
			':party:'        => '🥳',
			':thinking:'     => '🤔',
			':sweat:'        => '😅',
			':cry:'          => '😢',
			':sleep:'        => '😴',
			':rocket:'       => '🚀',
			':zap:'          => '⚡',
			':warning:'      => '⚠️',
			':tada:'         => '🎉',
			':coffee:'       => '☕',
			':cake:'         => '🍰',
			':sun:'          => '☀️',
			':moon:'         => '🌙',
			':cloud:'        => '☁️',
			':rainbow:'      => '🌈',
			':flower:'       => '🌸',
			':dog:'          => '🐶',
			':cat:'          => '🐱',	
		];
		foreach($emoji_map as $code => $emoji){
    	$data['text'] = str_replace($code, $emoji, $data['text']);
	}
more bbcode with Picker, Sticky Post, Emojis with Picker.
remove bbcode, added Markdown with Picker Bar, added HTML Syntax ( Withelisted ) with Picker Bar.
**A toggle button solution was created in the post based on the prior one: Show more, then show fewer!**
Readme Update
change simple colapse to Toggle-Button functionality
change simple colapse to Toggle-Button functionality
added collapse/ expand Animation and some other Animations
added Translation to all lang .ini ( Show Less = "Show Less" )
removed 
`
[bbcode]
;bbtags[quote] = "<quote>{param}</quote>"
`
from config.ini
Added function to upload a maximum of 10 images.
Added a function to upload a maximum of 10 images.
Added a function to upload a maximum of 10 images.
Toggle "Show More" / "Show Less" was broken.
Copy link
Author

@el-choco el-choco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bbcode replaced with markdown --> done!
multiple photos per post --> done! ( max. 10 Images per Upload or Drag and Drop )
bigger screens --> done max-width is now 1000px but still responsive!
and added some other functionality like HTML Picker Bar, Smilies etc., tell me what you think.

Copilot AI review requested due to automatic review settings November 12, 2025 18:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request changes the post deletion mechanism from soft delete to hard delete, along with adding emoji support, UI improvements, and various configuration updates.

Key Changes

  • Hard Delete Implementation: Posts are now permanently deleted from the database instead of being marked as deleted (status=5)
  • Emoji Support: Added emoji shortcode conversion (:smile: → 😄) in post creation and editing
  • UI/UX Enhancements: Expanded layout widths, improved sticky post styling, multi-image gallery support, and collapsible text with "Show Less" functionality

Reviewed Changes

Copilot reviewed 24 out of 27 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
app/post.class.php Implements hard delete, adds emoji mapping (with duplication issues), fixes indentation
app/ajax.class.php Fixes spelling error, adds UTF-8 charset and emoji-safe JSON encoding
ajax.php Refactors method calling to use static invocation, improves code formatting
app/lang/*.ini Adds "Show Less" translations across all supported languages
config.ini Uncomments SQLite database path, removes BBCode section
docker-compose.yml Updates image source, timezone, and port mapping
static/styles/*.css Extensive CSS changes for layout widths, sticky posts, galleries, and responsive design
static/scripts/app.js Adds multi-image upload, sticky post toggle, collapsible text, and gallery features
static/images/* New cover and profile images

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 129 to 164
$emoji_map = [
':smile:' => '😄',
':laugh:' => '😂',
':wink:' => '😉',
':heart:' => '❤️',
':broken_heart:' => '💔',
':fire:' => '🔥',
':star:' => '',
':check:' => '',
':cross:' => '',
':thumbs_up:' => '👍',
':thumbs_down:' => '👎',
':clap:' => '👏',
':party:' => '🥳',
':thinking:' => '🤔',
':sweat:' => '😅',
':cry:' => '😢',
':sleep:' => '😴',
':rocket:' => '🚀',
':zap:' => '',
':warning:' => '⚠️',
':tada:' => '🎉',
':coffee:' => '',
':cake:' => '🍰',
':sun:' => '☀️',
':moon:' => '🌙',
':cloud:' => '☁️',
':rainbow:' => '🌈',
':flower:' => '🌸',
':dog:' => '🐶',
':cat:' => '🐱',
];
foreach($emoji_map as $code => $emoji){
$data['text'] = str_replace($code, $emoji, $data['text']);
}

Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The emoji mapping array is duplicated in both the insert() and update() methods (lines 129-164 and 183-217). This violates the DRY principle and makes maintenance harder. Consider extracting this to a private static method or class constant.

Example:

private static $emoji_map = [
    ':smile:' => '😄',
    // ... rest of mappings
];

// Then in both methods:
foreach(self::$emoji_map as $code => $emoji){
    $data['text'] = str_replace($code, $emoji, $data['text']);
}

Copilot uses AI. Check for mistakes.
];
foreach($emoji_map as $code => $emoji){
$data['text'] = str_replace($code, $emoji, $data['text']);
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent indentation: The code uses spaces for indentation but line 163 appears to use tabs. Ensure consistent indentation (spaces vs tabs) throughout the file.

Suggested change
}
}

Copilot uses AI. Check for mistakes.
':rainbow:' => '🌈',
':flower:' => '🌸',
':dog:' => '🐶',
':cat:' => '🐱',
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace on line 213 after :cat: mapping. Remove the tab/space character after the comma.

Suggested change
':cat:' => '🐱',
':cat:' => '🐱',

Copilot uses AI. Check for mistakes.
Comment on lines 180 to 261
public static function delete($r){
self::login_protected();
self::login_protected();

DB::get_instance()->query("
DELETE FROM `posts`
WHERE `id` = ?
", $r["id"]);

return true;
}
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing from soft delete (UPDATE status=5) to hard delete (DELETE) is a breaking change with significant implications:

  1. Data Loss: Deleted posts cannot be recovered
  2. Referential Integrity: This could break foreign key constraints if other tables reference posts
  3. Audit Trail: There's no record that a post existed and was deleted

Consider implementing cascading deletes for related data or adding a confirmation mechanism. If this is intentional, ensure backups are in place.

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this is a breaking change that could be hidden behind a feature flag. Maybe in config you could set whether you want to have soft or hard delete.

Also when doing hard delete, we should also remove images (if referenced by the post).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would indeed be a great solution, using the feature flag and putting it in the config.ini file.

Regarding deleting images... I completely forgot about that, I'll get on it!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added so much that I've lost track...


🎯 Summary

This PR introduces several major features and improvements:

  • Multi-image upload (up to 12 images per post)
  • German translations for all UI elements
  • Trash/Recycle Bin system with restore functionality
  • Sticky posts feature
  • Improved mobile responsiveness

✨ Features Added

1. Multi-Image Gallery System

  • Upload up to 12 images per post (previously 1)
  • Support for drag & drop multi-upload
  • Visual preview grid with remove buttons
  • Responsive grid layout (4 columns desktop, 2 columns mobile)
  • All images displayed in posts (no limit)

Files changed:

  • static/scripts/app.js
  • static/styles/custom1.css

2. German Language Support

  • Added __() translation function in common.php
  • Created lang/de.php with German translations
  • Translated all UI elements:
    • "Show More" / "Show Less" → "Mehr Anzeigen" / "Weniger Anzeigen"
    • "Delete Permanently" → "Endgültig Löschen"
    • All modal dialogs and buttons

Files changed:

  • common.php
  • lang/de.php (new file)
  • index.php
  • static/scripts/app.js

3. Trash/Recycle Bin Management

  • Soft delete posts to trash (configurable)
  • Restore posts from trash
  • Permanent delete from trash
  • Trash count indicator
  • Configurable via config.php:
    • SOFT_DELETE (default: true)
    • HARD_DELETE_FILES (default: true)

Files changed:

  • classes/post.class.php
  • index.php
  • static/scripts/app.js

4. Sticky Posts

  • Pin important posts to top of timeline
  • Visual indicator (📌 icon)
  • Toggle sticky status via post menu
  • Highlighted border for sticky posts

Files changed:

  • classes/post.class.php
  • static/scripts/app.js
  • static/styles/sticky_posts.css (new file)

5. Mobile Improvements

  • Centered image galleries on mobile
  • Uniform square image aspect ratio (1:1) on mobile
  • Full-width gallery on small screens
  • Fixed "Show More" toggle button

Files changed:

  • static/styles/custom1.css

📝 Files Changed

Modified Files:

  1. common.php

    • Added translation function __()
    • Added language detection
  2. classes/post.class.php

    • Added delete(), permanent_delete(), restore(), list_trash()
    • Added toggle_sticky() for sticky posts
    • Improved image deletion handling
  3. index.php

    • Added German translations throughout
    • Added trash view UI
    • Added data attributes for JS translations
    • Updated "Show More" button with translation
  4. static/scripts/app.js

    • Changed maxImages from 10 to 12
    • Fixed updateImageCounter() to use variable
    • Added multi-file drag & drop support in filedrop()
    • Added trash management functions
    • Fixed toggle button to use PHP translations
    • Fixed "Delete Permanently" dialog translations
  5. static/styles/custom1.css

    • Added layouts for 11 and 12 images
    • Fixed mobile centering (.b_content overflow: visible)
    • Added mobile responsive rules
    • Force square aspect ratio on mobile

New Files:

  1. lang/de.php - German translation strings
  2. static/styles/sticky_posts.css - Sticky post styles

🔧 Configuration

Add to config.php:

// Soft delete (move to trash instead of permanent delete)
define('SOFT_DELETE', true);

// Delete image files when permanently deleting posts
define('HARD_DELETE_FILES', true);
---
# **and some other Stuff**

header('Content-Type: application/json');
echo json_encode($this->_response);
header('Content-Type: application/json; charset=utf-8');
// WICHTIG: JSON_UNESCAPED_UNICODE damit Emojis richtig übertragen werden
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment is in German while the rest of the codebase uses English comments. For consistency, consider:

// IMPORTANT: JSON_UNESCAPED_UNICODE ensures emojis are transmitted correctly
Suggested change
// WICHTIG: JSON_UNESCAPED_UNICODE damit Emojis richtig übertragen werden
// IMPORTANT: JSON_UNESCAPED_UNICODE ensures emojis are transmitted correctly

Copilot uses AI. Check for mistakes.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it should be in EN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants