GithubHelp home page GithubHelp logo

baraja-core / cms Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 3.0 1.95 MB

🛠️ Simple smart CMS for Nette and Vue.js

Home Page: https://baraja.cz/cms

License: MIT License

PHP 26.51% HTML 1.10% CSS 1.00% JavaScript 61.18% Latte 10.21%
nette baraja-cms vue administration-interface vue-components articles sense cms content user user-manager permissions plugin plugins plugin-manager plugin-cms handles cms-framework cms-backend

cms's Introduction


Baraja CMS

Baraja CMS is a new generation administration system written in the latest technologies for PHP. Read more on the official product page.

Baraja CMS login form

Baraja CMS (Content manage system) is an administration interface for content management of websites and e-shops. The content is managed by the client himself, so it is necessary to carefully debug the individual functional elements.

Basic philosophy

Baraja CMS was designed as a simple, fully stand-alone application that allows you to log in to the website and manage it intelligently.

The package automatically ensures the creation of the basic software of the project (basic database tables, user profiles, admin panel and support for plugins).

Because each project is a little different, this administration interface can automatically adapt to the project where it is running. This was achieved mainly by the fact that the CMS itself has the smallest possible dependencies and the individual functions are supplied by the installed plugins. The CMS then provides communication between them and renders the data to the user.

Installation

Installation is possible only with Composer:

$ composer require baraja-core/cms

After installing the package, register the DIC extension to ensure complete configuration of all services.

Please use in your common.neon:

extensions:
   cms: Baraja\Cms\CmsExtension

Plugins and extensions

The CMS has been created for scalability since the original design.

Extensions are made through so-called plugins, which can be defined anywhere. The CMS is therefore fully independent of the specific project implementation and we can combine plugins from different sources (most often plugins from installed packages supplemented by plugins from a specific project implementation).

Because plugins are often defined within specific packages, which do not necessarily depend on the CMS, it makes great sense to implement plugins elsewhere in a separate package that requires both a specific package (such as articles) and the CMS itself that obtains data from it. This package is called Plugin system and defines a general environment for all types of services, components, plugins and the links between them.

Custom plugin and view types

A general plugin is defined as an unfocused entity. Only the CMS makes sense to it, because it defines the way it will be rendered.

To make it easy to define and extend new features, the CMS defines a set of basic layout templates and components to which plugins provide content based on which page the user is on.

The page URL has the following forms:

  • /admin (the system HomepagePlugin with default action will be rendered)
  • /admin/article (ArticlePlugin with default actions` will be rendered)
  • /admin/article/detail (ArticlePlugin with detail actions will be rendered)
  • /admin/article/detail?id=1 (ArticlePlugin with detail action is drawn and the parameter id=1 is passed)

Each plugin reserves its own namespace in the URL (for example Article) and only it can interfere with its content. At the same time, it reserves all combinations of addresses with the specified namespace (for example, article/create), which the plugin developer can freely use.

Remember:

Rendering a specific page in the CMS always means creating an instance of a specific plugin with its specific view.

Plugin and its default view

If the plugin contains only one component, it will have the entire page space to itself. In this case, the developer needs to implement a complete page layout.

In order for all pages to be the same and only their content to change, we have prepared a set of ready-made layout components that define the general layout of the elements on the page and can be easily used by the developer.

For example, defining an overview of articles with a title, crumb navigation, buttons, and main table content might look elegant:

Vue.component('article-default', {
    template: `<cms-default title="Article manager" :breadcrumb="breadcrumb" :buttons="buttons">
        <b-modal id="modal-new-article" title="Compose a new article">
            <textarea class="w-100 form-control"></textarea>
        </b-modal>
        <table class="table table-sm">
            <tr>
                <th>Title</th>
            </tr>
            <tr>
                <td>We have created a new website!</td>
            </tr>
        </table>
    </cms-default>`,
    data() {
        return {
            breadcrumb: [
                {
                    label: 'Dashboard',
                    href: '#'
                },
                {
                    label: 'Articles',
                    href: '#'
                }
            ],
            buttons: [
                {
                    variant: 'primary',
                    label: 'Compose a new article',
                    icon: 'fa-plus',
                    action: 'modal',
                    target: 'modal-new-article'
                },
                {
                    variant: 'danger',
                    label: 'Click here',
                    action: 'linkTab',
                    target: '/'
                }
            ]
        }
    }
});

Note that the <cms-default> component was used to render the main page layout, which serves as the default layout.

Plugin with a group of components (bookmarks)

Most plugins allow you to edit the parent entity in a detailed view that we want to contain more than one component.

CMS has native support for chaining two or more components into bookmarks, where only the first bookmark and the other lazy are automatically drawn when the page is loaded, after clicking on the bookmark name. If the user switches multiple tabs, those already open remain loaded in the operating memory so that he can work with them again without further delay.

The bookmarked design is rendered automatically when there are at least 2 components on the page. For this to happen, the routing must match for one plugin with either multiple components that have the same view (property view) or multiple plugins whose home entity meets a common interface to the currently rendered plugin (for example, an SEO component is automatically rendered), and at the same time it corresponds to the type of view (the behavior may differ, for example, for comparators, when we want to draw a different type of component in the category and another type in the product detail).

However, the general layout of the component cannot be used on the detail page, because all components are drawn inside the bookmarks and the bookmark system itself defines the CMS automatically within the internal logic.

In order to be able to influence the appearance of the page (and especially the content), the CMS implements optional extensions.

Most often we want to draw, for example, the detail of the article, while:

  • We will place the name of the current article in the header according to its ID in the URL
  • According to the installed plugins and available routes, we will display the control buttons
  • We will generate crumb navigation (which may vary by category and other factors)
  • We draw internal components for editing (article content, category management and history)
  • We draw related components (such as SEO), but the CMS does this automatically
  • We will set other control properties for the user, such as the Save all button and more

For all this to work, the base class for the Plugin needs to be extended. This is ensured by the plugin inheriting the BasePlugin class in the Plugin system package, which adds additional optional behaviors and custom helpers.

Therefore, when creating a plugin instance and rendering it to the CMS, the so-called "action" method in the form of action<ActionName> is called first, and it can accept URL parameters as function arguments. The behavior is similar to the Nette framework in the case of Presenter.

Technically, it can look like this in the code, for example:

final class ArticlePlugin extends BasePlugin
{
    public function actionDetail(string $id): void
    {
        $this->setTitle('Detail článku');

        $this->addButton(new Button(
            Button::VARIANT_INFO,
            'My button',
            Button::ACTION_LINK_TAB,
            '/'
        ));

        $this->addBreadcrumb(new Breadcrumb('Hlavní strana', '/'));
        $this->addBreadcrumb(new Breadcrumb('Kategorie článku', '/category'));
        $this->addBreadcrumb(new Breadcrumb('Další kategorie', '/category-2'));
        $this->addBreadcrumb(new Breadcrumb('Název článku', '/article/detail?id=1'));
    }
}

Important notes:

  • Within the plugin, you can get instances of other services via the constructor (this is a common Nette service), so it's a good idea to inject ArticleManager and then use it.
  • The title (setTitle() method) can be defined dynamically depending on which article I am currently on.
  • For more complex cases, also set a subtitle (setSubtitle() method).
  • Buttons (addButton() and addContextMenu() methods) can be freely defined and it is a good idea to expand their list according to the availability of other functions for users. Buttons can open links (in the same or a new window), open modals or call a javascript function (in the case of a method within a Vue component).
  • For the Back button to work, you need to define the URL of the previous page with the setLinkBack() method.
  • The Save All button must be enabled over a specific plugin by calling the setSaveAll(true) method).
  • If you can, set up a context menu with useful links for users (for example, to display an article on the front end or various links to available language versions of the article).

Loading styles and scripts

All CSS styles of the entire CMS are minified into one large file and stored on the Baraja CDN server. The main reason is that the installation of the CMS does not require any additional dependencies, which would, for example, require the CMS to contain a style file and it must return to a special URL.

Thanks to this principle, we have all styles under control and the plugin developer does not have the opportunity to change anything in them. This is the only way to ensure that all plugins and components use a basic defined design system (Bootstrap + our helpers) and that all parts of the CMS look almost the same.

However, scripts are defined by each plugin separately, in the form of Vue components.

The CMS core ensures the assembly of all components for a given plugin and their joint assembly into one large javascript file, which is downloaded to the user when opening the first page with the plugin. Furthermore, it has the entire plugin downloaded in the cache and can very effectively control only specific components. This service serves as a Proxy tunnel, which allows you to load javascript from different physical locations at once (most often from a vendor in combination with its own components within a specific project).

Vue components should use only pre-built styles and other CMS components to look as similar as possible and the user immediately understands their main principles.

cms's People

Contributors

dependabot-preview[bot] avatar filipjakub avatar janbarasek avatar langriklol avatar stralkaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cms's Issues

Disk capacity

V rámci nastavení CMS by se hodilo uživateli zobrazovat, jak je na tom kapacitně jeho disk na serveru.

Zkus připravit třídu, která bude poskytovat informace o discích a jakou mají kapacitu. Představuji si to tak, že zavolám něco jako:

Disk::getOverview();

A jako response dostanu pole dostupných disků a kapacity. Pozor, pole disků se liší podle operačního systému (na Windows jsou disky A-Z, na Linuxu se tzv. mountují).

Možná response:

[
   // disk => [dostupná kapacita, použitá, celková],
   'c' => ['available' => int, 'used' => int, 'total' => int],
]

Pomocné funkce:

  • free space: disk_free_space()
  • total space: disk_total_space()
  • Add disk total space detection by project root dir

Na Windows teoreticky takto (nevyzkoušeno):

function getDisks(): array
{
    if (str_contains(PHP_OS_FAMILY, 'WIN')) {
        $return = [];
        foreach (range('A', 'Z') as $disk) {
            $return[$disk] = disk_total_space($disk . ':');
        }

        return $return;
    }

    return [
        '/' => disk_total_space('/')
    ];
}

Hlavní menu

V rámci CMS používáme základní design pro levé menu, kde jsou dostupné všechny aktivní pluginy. Cílem tohoto úkolu je připravit nový moderní design, který zapadá do koncepce celého CMS a vypadá moderně.

Současný design

Snímek obrazovky 2022-02-25 v 10 31 56

Akceptační kritéria

  • Název pluginu
  • Ikonka pluginu (může neexistovat)
  • Nakreslit aktivní (musí být snadno rozpoznatelné, kde zrovna jsem) a neaktivní variantu
  • Hover varianta (při najetí myší) musí být rovnou vidět
  • V debug mode se zobrazuje aktuálně nastavené pořadové score každé položky
  • Připravit rovnou i tzv. odznak na aplikaci, který uživateli ukáže, že se v aplikaci něco děje a kolik (inspirace z červeného labelu na iPhone)

Aktivní debug režim s zobrazením hodnocení pluginů

Snímek obrazovky 2022-02-25 v 10 36 29

Inspirace z iPhone, jak řešit aktivní notifikaci na položce menu

Snímek obrazovky 2022-02-25 v 10 37 44

Jak menu řešit?

Přemýšlel jsem nad tím hodně a nevím. Možná bych šel do designu ve stylu nového Gmailu:

Snímek obrazovky 2022-02-25 v 10 39 02

Požadavky na použitelnost

Menu musí být maximálně použitelné. Pamatuj vždy na jednoduchost a jednoznačnost všech stavů pro všechny uživatele v různých kontextech. Vybraná položka musí být dobře vidět na všech typech zařízení, i na levném notebooku na přímém slunci. Zároveň nesmí položky příliš vizuálně vyrušovat uživatele.

Velmi brzy budeme CMS přepisovat do plně responsivní varianty a design menu musí být připraven i pro mobilní zařízení. Zkus na to při návrhu myslet.

Děkuji.

Nástěnka

Cílem tohoto úkolu je zpracovat obecný návrh dashboardu (zatím jako grafický návrh, o kterém se bude diskutovat).

Nyní je na dashboardu panel pro psaní příspěvků a sdílení s týmem. Tento modul chceme zachovat, abychom podpořili komunikaci v rámci týmu. Každý příspěvek může mít komentáře, které se umí stromově zanořovat.

V rámci dashboardu ale chceme umožnit vkládat vlastní widgety a pluginy. Zkus vymyslet, jak by mohl obecný widget vypadat, jakým způsobem se bude do stránky vkládat, jak bude fungovat jejich organizace (pořadí, poloha, ...) a podobně. Můžeme jít buď směrem Seznam homepage, nebo widgetů na iPhonu.

Demo:

Snímek obrazovky 2021-08-15 v 13 20 10

Předchozí poznámky:

  • Možnost pinovat příspěvky (bool)
  • Komentáře
  • Likování
  • Vlastní moduly - musí definovat plugin
  • Kontakty na členy týmu - možnost u userů nastavit roli
  • Zvážit: Ukládat jako denormalizovaná data

Notification center

Připrav grafický návrh pro notifikační centrum v CMS.

Libovolný modul může poslat libovolnému uživateli notifikaci. Notifikace se musí agregovat s možností je zobrazit, spravovat a mazat. Mazání by mělo fungovat i hromadně.

Všechny notifikace by měly vypadat stejně s customizovatelnou ikonkou, názvem, textem notifikace. Volitelně může obsahovat obrázek a akční tlačítka. Notifikace musí jít prokliknout do detailu (přes akční tlačítko).

Příklad, jak to řeší Mac:

Snímek obrazovky 2021-08-15 v 13 22 50

  • Verejny api endpoint pro zjisteni posledni verze cms
  • Automaticka diagnostika systemovych prostredku (upload limit a podobne) a kdyz bude spatne nebo malo, ukazat notifikaci

Version and update checker

Show date of last update. Check for updates by call CDN API endpoint (not if user is offline).

When update is ready show info on dashboard for all admins.

Editable annotation crashes application

Version: latest

Bug Description

When running composer update or composer dump the command appropriate for running application crashes due to missing import.
image

Steps To Reproduce

Run composer dump on latest version of package

Expected Behavior

Not to crash application

Possible Solution

Maybe consider refactoring as PHP attribute

CMS users - role

Definovat systém rolí a popisu uživatele

  • Lidsky napsaná role do stringu
  • Popis uživatele
  • Reporting to - relace na parent usera, kdo je nadřízený
  • Týmy - relace uživatele na tým pro lepší vykreslování struktury společnosti a pochopení, s kým kdo spolupracuje
  • Možnost vykreslit hierarchii uživatelů v projektu
  • Obecna komponenta pro zobrazeni uzivatelskeho avatara + jmeno -> po najeti hover okno s popisem uzivatele a hierarchii jako ve webovem Outlooku

Install proces

Zkus projít celý proces instalace CMS do nového projektu, jestli dává všechno smysl.

Pole, kde si nebudeš jistý, zkus více popsat.

Zamysli se nad designem a možnostmi pokročilejší grafiky, aby to vypadalo víc advance.

Díky.

Instalační proces

Úkolem je zjednodušit celou instalaci.

Debugnout celý proces registrace Baraja CMS do cloudu + informace o nutnosti vyčkání na mail + následné přihlášení do účtu, až když se aktivuje link

Global CMS settings

Cílem tohoto úkolu je vymyslet vzhled a ovládání globálního nastavení CMS i celé aplikace/webu/e-shopu.

Nastavení bude koncipováno jako modální okno, které se otevře po kliknutí na tlačítko na admin baru.

Nyní se zobrazuje takto:

Snímek obrazovky 2021-08-13 v 10 41 42

Cílem tohoto úkolu je vymyslet a připravit vzhled tohoto okna.

Na co nezapomenout:

  • Nastavení musí fungovat obecně, tj. na hlavním pohledu budou vidět dostupné kategorie nastavení, které má každý projekt jinak
  • Ideálně bych v rámci nastavení zobrazoval levé menu, kde bude seznam pluginů, které umožňují vnitřní nastavení. Hodně se tím zjednoduší návrh a bude zřejmé, co vše mohu nastavovat
  • Levé menu by mělo mít vlastní posuvník, pokud bude obsahovat hodně položek
  • V první fázi řeš jen design. Protože jde o obecnou komponentu, která musí být snadno dostupná napříč systémy, tak naopak použij přímé stylování přes HTML attribut style
  • Výstupem úkolu bude nakódovaný HTML modul, který pak já převedu na Vue komponentu, proto ho dodej třeba jako HTML soubor, který vložíš sem do komentáře

Inspirace, jak nastavení řeší třeba Webnode:

Snímek obrazovky 2021-08-08 v 18 38 29

Init modalu: 5b46a62

Díky.

Login sessions management

Implement custom logic for session management. Use existing table to store history.

In the account detail view:

  • List of actively logged sessions that have not been marked as logged out.
  • Ability to see which sessions are currently online (including propagating status to other application layers)
  • A button to log out all sessions other than the acoustic one
  • Button to log out all sessions, including the current one
  • Automatic logout of all sessions if the user is locked out

Sessions must be authenticated in keep-auth requests. If the session is no longer valid, automatically log the user out.

Allow administrators to log out sessions of all other users (security).

Activity on this account

Add summary table with account activity based on sessions data.

image

If more than one session is active, show the information in the footer of all pages in the admin. Verify with ajax at least once a minute.

Snímek obrazovky 2022-01-31 v 17 41 55

Lock screen

I often need to lend a computer to a colleague for a moment and quickly log out of my account. Allow me to set a session lock. Show the active logged in user and allow to enter the password directly to open access.

It will also automatically switch the user to lock mode if they have not been active for more than 3 days.

Fail to ban

Implement service and move firewall checking from login process.

Zprovoznit translator na frontendu

  • Jak jsem vyházel přebytečné knihovny, tak přestal fungovat translator na frontendu
  • Prosím citlivě to zprovniznit, tzn. přidat jen nezbytné knihovny, ověřit aby tam nebyly 2x a aby se načítaly jen pro adminy, ne pro návštěvníky

Video support

  • Možnost odeslat redirect na konkrétní stránku
  • Rozlišení obrazovky, OS, prohlížeč, další technické info...
  • Zobrazení pozice kurzoru uživatele i technika, možnost kliknout na konkrétní místo přes volání selectoru událostí
  • Možnost vložení šipky, textu a obrazce na konkrétní místo (div position absolute), vázat ke konkrétní URL, aby to zůstalo i po pomoci
  • Během sdílení nabídnout tlačítko pro rychlé ukončení hovoru z obou stran. Nabídnout interaktivní živý chat + zobrazit telefonní číslo technické podpory pro přenos hlasu
  • Možnost odeslání souboru přes chat až do kapacity 10 MB (jen obrázkové formáty, pdf a office)

Settings

Add common settings interface.

Dark mode

Detect:

if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
    // dark mode
}

To watch for changes:

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', e => {
    const newColorScheme = e.matches ? "dark" : "light";
});

Náhradní kódy

Při založení ověření OTP vygenerovat sérii náhradních kódů, které donutíme uživatele bezpečně uložit + potvrdit uložení.

Náhradní kódy jsou jediná cesta, jak získat přístup k vašemu účtu, pokud ztratíte přístup k vašemu zařízení a tím pádem nemůžete získat kódy dvoufázového ověření.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.