Light Portal

Started by Bugo, March 25, 2020, 07:36:36 AM

Previous topic - Next topic

Bugo

You need to make a small fix in the file Sources\LightPortal\Addons\SimpleChat\template.php:

https://github.com/dragomano/Light-Portal/commit/8dfa35efb1f84a01334caa65b856fd893f6e7c76

JRMBelgium

Quote from: Bugo on September 17, 2024, 02:43:53 PMYou need to make a small fix in the file Sources\LightPortal\Addons\SimpleChat\template.php:

https://github.com/dragomano/Light-Portal/commit/8dfa35efb1f84a01334caa65b856fd893f6e7c76

I fixed more than that:
- HTML now working
- No mor ugly scrollbars
- Separate lines for avatar+username, text and date+trashcan.
- Input-window + chatbutton at the top, not the bottom.

<?php

use Bugo\Compat\{ConfigLangUtils};

function 
show_chat_block(int $idbool $show_avatarsbool $full_width): void
{
    echo 
/** @lang text */ '
    <script>
        const chat'
$id' = new SimpleChat("'LP_ACTION'", ', (Utils::$context['lp_chats'][$id] ?: '[]'), ');
    </script>

    <div x-data="chat'
$id'.handleComments()" style="display: flex; flex-direction: column; height: 500px;">
        '
;

    if (
Utils::$context['user']['is_logged']) {
        echo 
'
        <form @submit.prevent="addComment($refs)" style="margin-bottom: 10px;">
            <div class="'
$full_width 'full_width' 'floatleft'' post_note">
                <input type="text" required x-ref="message" autofocus @keyup="$refs.submit.disabled = !$event.target.value">
            </div>
            <button class="button '
$full_width 'full_width' 'floatright''" disabled x-ref="submit" data-block="'$id'">'Lang::$txt['post'], '</button>
        </form>'
;
    } else {
        echo 
'
        <a href="'
Config::$scripturl'?action=login" onclick="return reqOverlayDiv(this.href, 'Utils::escapeJavaScript(Lang::$txt['login']), ');">'Lang::$txt['lp_simple_chat']['login'], '</a>';
    }

    
// Clean up layout to ensure proper alignment and spacing of avatar, username, message, and controls
    
echo '
        <ul class="moderation_notes" style="flex-grow: 1; overflow-y: hidden; padding: 0; margin: 0; list-style-type: none; max-height: 100%;">
            <template x-for="(comment, index) in comments" :key="index">
                <li class="smalltext" style="margin-bottom: 15px;">
                    <div style="display: flex; align-items: center;">
                        '
$show_avatars === true '<span x-html="comment.author.avatar ?? null" style="margin-right: 10px;"></span>' '''
                        <strong x-text="comment.author.name" style="font-weight: bold;"></strong>
                    </div>
                    <div style="margin-top: 5px;">
                        <span x-html="comment.message" style="display: block;"></span>
                    </div>
                    <div style="display: flex; justify-content: space-between; margin-top: 5px;">
                        <span class="floatleft" x-html="comment.created_at"></span>
                        '
Utils::$context['user']['is_admin'] ? ' <span class="main_icons delete" style="cursor: pointer;" @click="removeComment($refs, index, comment.id)"></span> ' '''
                    </div>
                </li>
            </template>
        </ul>
    </div>'
;
}

Bugo

Thanks, I'll add that as an alternative option to the chat settings.

Bugo

However, how are you going to scroll chat messages without scrollbars? Also, all inline styles would look better in style.css.

JRMBelgium

Quote from: Bugo on September 20, 2024, 11:54:37 PMHowever, how are you going to scroll chat messages without scrollbars? Also, all inline styles would look better in style.css.

There is no need. I don't expect more then 1 message per day. It can be easy way for someone to write "guys, i'm on holidays for the next week, will be afk" or something like that.

marcosbr

I would like to allow admin and moderators. Is there a way to do this?

Do you feel superior?
Above is a slab and below is darkness. It's fire brother!
https://amigosdaeletronica.com.br

Bugo

There is already a dedicated chat box for this in the Moderation section of SMF itself. But if you need this permission specifically for portal blocks, I'll try to add it in the next version.

marcosbr

 Thanks!
 It's exactly to display on the portal!
Do you feel superior?
Above is a slab and below is darkness. It's fire brother!
https://amigosdaeletronica.com.br

Bugo

And which moderators exactly are you referring to? Global? Or board moderators?

marcosbr

#369
I only have board moderators
Do you feel superior?
Above is a slab and below is darkness. It's fire brother!
https://amigosdaeletronica.com.br

Aleksi "Lex" Kilpinen

Board moderators are generally only recognized as moderators, inside the boards they moderate, so for other general use you would likely need to set up a separate membergroup to add all local moderators to, so you can use that membergroup to identify if someone is a local moderator.
Slava
Ukraini!
"Before you allow people access to your forum, especially in an administrative position, you must be aware that that person can seriously damage your forum. Therefore, you should only allow people that you trust, implicitly, to have such access." -Douglas

How you can help SMF

Bugo

So you want a particular chat block to be available to board moderators only in boards in which they are moderators or in all areas of the forum?

marcosbr

#372
]Yes!
The chat would be in all areas of the forum precisely to facilitate communication.
I always used it on other portals and never had a "global" moderator


Edit -  STOP USING THOSE PRE TAGS

Do you feel superior?
Above is a slab and below is darkness. It's fire brother!
https://amigosdaeletronica.com.br

marcosbr

#373
"Edit -  STOP USING THOSE PRE TAGS"

How this appears in the message I don't know...

Do you feel superior?
Above is a slab and below is darkness. It's fire brother!
https://amigosdaeletronica.com.br

Bugo

Welcome to update 2.8!

Now you can restore deleted pages if you change your mind. Deleted pages won't show up anywhere except in a special section in the admin panel. You can also permanently delete them from there if needed.

Instead of extended statuses, all pages now have a new feature - entry type. By default, there are 3 types of pages: standard (the ones that show up on the homepage as articles), internal (pages that don't show anywhere but can be added to the forum menu or accessed via a direct link), and draft (pages visible only to their authors). Only admins can create internal pages. You can add other types for your needs using plugins. For example, the BlogMode plugin adds a blog post type to display user pages in a separate blog section of the forum. For user convenience, there's also a dropdown in the admin page list to sort pages by entry type.

A new viewing permission has been added for blocks and pages - "Show to Moderators". This applies to both board moderators and global ones.



Addons have been renamed to plugins. All plugins are now physically located in the `Sources/LightPortal/Plugins` directory. There's also an event manager for plugins. With the "Light Portal" tab in SMF Tracy Debugger, you can see a list of all portal hooks, events, and the plugins subscribed to them.

Global documentation update: translations have been added in Arabic, German, Spanish, Turkish, Ukrainian, French, and Dutch. If you want to improve or add a new translation, join the Crowdin system. As practice has shown, not everyone understands how to switch the language of the documentation and uses the built-in translator in the browser. Therefore, I am specifically posting a screenshot with an image of the required button:



As an experiment, the interface of the first settings page has been changed - now all settings are organized into tabs, just like when editing pages and blocks. Be sure to check how this interface works in the mobile version.



As usual, bugs have been fixed and some translations have been updated.

At first, make sure to update the Optimus 3.0 if it is installed.

You can update without reinstalling only from version 2.7.*. If your version is below 2.7, first update to 2.7, or completely remove the portal (after exporting the necessary pages and blocks), and then install the latest version from scratch.

TeamKC

Hello Bugo,

The update for your portal is amazing, but it gives one problem.

When we have the who-is-Online block active with avatars showing it gives us links instead of the names and their avatar, it happens on mobile and pc, I have pictures to show what I mean.

When we have only name with title on or name with title off it works fine, but as soon as we turn on show avatar it doesn't work the way it should.


Greetings,
TeamKC

Tyrsson

Quote from: Bugo on November 10, 2024, 11:46:22 PMWelcome to update 2.8!

Now you can restore deleted pages if you change your mind. Deleted pages won't show up anywhere except in a special section in the admin panel. You can also permanently delete them from there if needed.

Instead of extended statuses, all pages now have a new feature - entry type. By default, there are 3 types of pages: standard (the ones that show up on the homepage as articles), internal (pages that don't show anywhere but can be added to the forum menu or accessed via a direct link), and draft (pages visible only to their authors). Only admins can create internal pages. You can add other types for your needs using plugins. For example, the BlogMode plugin adds a blog post type to display user pages in a separate blog section of the forum. For user convenience, there's also a dropdown in the admin page list to sort pages by entry type.

A new viewing permission has been added for blocks and pages - "Show to Moderators". This applies to both board moderators and global ones.



Addons have been renamed to plugins. All plugins are now physically located in the `Sources/LightPortal/Plugins` directory. There's also an event manager for plugins. With the "Light Portal" tab in SMF Tracy Debugger, you can see a list of all portal hooks, events, and the plugins subscribed to them.

Global documentation update: translations have been added in Arabic, German, Spanish, Turkish, Ukrainian, French, and Dutch. If you want to improve or add a new translation, join the Crowdin system. As practice has shown, not everyone understands how to switch the language of the documentation and uses the built-in translator in the browser. Therefore, I am specifically posting a screenshot with an image of the required button:



As an experiment, the interface of the first settings page has been changed - now all settings are organized into tabs, just like when editing pages and blocks. Be sure to check how this interface works in the mobile version.



As usual, bugs have been fixed and some translations have been updated.

At first, make sure to update the Optimus 3.0 if it is installed.

You can update without reinstalling only from version 2.7.*. If your version is below 2.7, first update to 2.7, or completely remove the portal (after exporting the necessary pages and blocks), and then install the latest version from scratch.
Well done!!
PM at your own risk, some I answer, if they are interesting, some I ignore.

Bugo

Excellent catch, thank you! :) You'll need to open Sources/LightPortal/Plugins/WhosOnline and find that code:

        // With avatars
        if ($parameters['show_avatars']) {
            $users = array_map(fn($item) => Avatar::get($item['id']), $whoIsOnline['users_online']);

            $whoIsOnline['list_users_online'] = [];
            foreach ($whoIsOnline['users_online'] as $key => $user) {
                $whoIsOnline['list_users_online'][] = Str::html('a', $users[$key])
                    ->href(Config::$scripturl . '?action=profile;u=' . $user['id'])
                    ->title($user['name']);
            }
        }

and replace it with this

        // With avatars
        if ($parameters['show_avatars']) {
            $users = array_map(fn($item) => Avatar::get($item['id']), $whoIsOnline['users_online']);

            $whoIsOnline['list_users_online'] = [];
            foreach ($whoIsOnline['users_online'] as $key => $user) {
                $whoIsOnline['list_users_online'][] = Str::html('a', '')
                    ->href(Config::$scripturl . '?action=profile;u=' . $user['id'])
                    ->title($user['name'])
                    ->addHtml($users[$key]);
            }
        }

~Souza~

I got everything installed and 'manage plugins' was working. Now I needed to go back and I get this (see attachment). What happened? Help! LOL

~Souza~


Advertisement: