Author: 779rd5fmjvci

  • epiphany

    Epiphany

    Open Source Ruby on Rails engine to build Custom Voice Assistants

    Usage

    *Currently in Alpha

    Installation

    The configs for each model are stored in a traditional relational database. For now we are using postgres in our examples. https://medium.com/@noordean/setting-up-postgresql-with-rails-application-357fe5e9c28
    Add this line to your Rails application’s Gemfile:

    gem 'pg'
    gem 'epiphany', git: "https://github.com/geekdreamzz/epiphany.git", branch: "alpha"

    And then execute:

    $ bundle

    generate initial models & migration

    rails g epiphany:install
    rake db:migrate

    Mount the Engine in routes.rb, example:

    mount Epiphany::Engine => "/epiphany"

    You can add custom authorization logic. Let’s say you had an application helper method in your app named :quick_auth which you’d like to use to enforce authentication. You can configure the Epiphany library to reference that when using the epiphany admin web interface. Add something like this in a file in the initializers directory:

    Epiphany::Config.set do |config|
      config.auth = :quick_auth
    end

    Contributing

    Send Me a Message or submit a PR 🙂

    License

    The gem is available as open source under the terms of the MIT License.

    Visit original content creator repository
    https://github.com/geekdreamzz/epiphany

  • rentx

    Cadastro de carro

    Requisitos Funcionais

    • Deve ser possível cadastrar um novo carro.
    • Deve ser possível listar todas as categorias.

    Regras de Negócios

    • Não deve ser possível cadastrar um carro com uma placa já existente.
    • O carro deve ser cadastrado por padrâo, como disponível para locação.
    • O usuário responsável pelo cadastro deve ser um usuário administrador.

    Listagem de carros

    Requisitos Funcionais

    • Deve ser possível listar todos carros os carros disponíveis.
    • Deve ser possível listar todos os carros disponíveis pelo nome da categoria.
    • Deve ser possível listar todos os carros disponíveis pelo nome da marca.
    • Deve ser possível listar todos os carros disponíveis pelo nome do carro.

    Regras de Negócios

    • O usuário não precisa estar logado no sistema.

    Cadastro de Especificação no carro

    Requisitos Funcionais

    • Deve ser possível cadastrar uma especificação para um carro.

    Regras de Negócios

    • Não deve ser possível cadastrar uma especificação para um carro não cadastrado.
    • Não deve ser possível cadastrar uma especificação já existente para o mesmo carro.
    • O usuário responsável pelo cadastro deve ser um usuário administrador.

    Cadastro de imagens do carrro

    Requisitos Funcionais

    • Deve ser possível cadastrar a imagem do carro.

    RNF

    • Utilizar o multer para upload dos arquivos.

    Regras de Negócios

    • O usuário deve poder cadastrar mais de uma imagem para o mesmo carro.
    • O usuário responsável pelo cadastro deve ser um usuário administrador.

    Aluguel de carro

    Requisitos Funcionais

    • Deve ser possível cadastrar um aluguel.

    Regras de Negócios

    • O aluguel deve ter duração mínima de 24 horas
    • Não deve ser possível cadastrar um novo aluguél caso já exista um aberto para o mesmo usuário.
    • Não deve ser possível cadastrar um novo aluguél caso já exista um aberto para o mesmo carro.
    • Ao realizar um aluguel, o status do carro deverá ser alterado para indisponível

    Devolução do carro

    Requisitos Funcionais

    • Deve ser possível realizar a devolução de um carro

    Regras de Negócios

    • Se o carro for devolvido com menos de 24 horas, deverá ser cobrada a dirária completa.
    • Ao realizar a devolução, o usuári odeverá ser liberado para realizar um novo aluguel.
    • Ao realizar a devolução, deverá ser calculado o total do aluguel.
    • Caso o horário da devolução seja superior ao horário previsto da entrega, deverá ser cobrada uma multa proporcional aos dias de atraso.
    • caso haja multa, devertá ser somado o valor ao valor total do aluguél
    • O usuário deve estar logado na aplicação.

    Listagem de Alugueis para usuário

    Requisitos Funcionais

    • Deve ser possível realizar a busca de todos os alugueis para o usuário

    Regras de Negócios

    • O usuário deve estar logado na aplicação

    Recuperar Senha

    Requisitos Funcionais

    • Deve ser possível o usuário recuperar a senha informando o e-mail
    • O usuário deve receber um email com o passo a passo para a recuperação de senha
    • O usuário deve conseguir inserir uma nova senha

    Regras de Negócios

    • O usuário precisa informar uma nova senha
    • o link enviado para a recuperação de senha deve expirar em 3 horas

    Visit original content creator repository
    https://github.com/8bitbeard/rentx

  • landmark

    Landmark Explanation

    Landmark Explanation is an Entity Matching specific explanation framework based on LIME.

    The state of the art approaches for performing Entity Matching (EM) rely on machine & deep learning models for inferring pairs of matching / non-matching entities. Although the experimental evaluations demonstrate that these approaches are effective, their adoption in real scenarios is limited by the fact that they are difficult to interpret. Explainable AI systems have been recently proposed for complementing deep learning approaches. Their application to the scenario offered by EM is still new and requires to address the specificity of this task, characterized by particular dataset schemas, describing a pair of entities, and imbalanced classes. This paper introduces Landmark, a generic and extensible framework that extends the capabilities of a post-hoc perturbation-based explainer over the EM scenario. Landmark generates perturbations that take advantage of the particular schemas of the EM datasets, thus generating explanations more accurate and more interesting for the users than the ones generated by competing approaches.

    Framework

    Landmark flow

    Quick Start: Landmark Explanation in 30 seconds

    Run:

    git clone https://github.com/softlab-unimore/landmark.git
    pip install -r landmark/requirements.txt

    Import Landmark

    from landmark import Landmark

    Initialize it passing the predict method of your model.

    explainer = Landmark(model.predict, df, exclude_attrs=['id','label'], lprefix='left_', rprefix='right_')

    Explain EM model over an element of your data.

    el = df.sample()
    exp = explainer.explain(el)

    Plot your explanation

    explainer.plot(exp, el)

    Working example

    Get started with Landmark Explanation!

    Here you can find a working notebook in which we explain a Magellan model.

    Here you can find a working notebook in which we explain a DeepMatcher model.

    Reference

    For a detailed description of the work please read our papers. Please cite the paper if you use the code from this repository in your work. Using landmarks for explaining entity matching models

    @inproceedings{DBLP:conf/edbt/BaraldiBP021,
      author    = {Andrea Baraldi and
                   Francesco Del Buono and
                   Matteo Paganelli and
                   Francesco Guerra},
      title     = {Using Landmarks for Explaining Entity Matching Models},
      booktitle = {{EDBT}},
      pages     = {451--456},
      publisher = {OpenProceedings.org},
      year      = {2021}
    }
    

    Check out our demo as well: Landmark explanation: An explainer for entity matching models

    License

    MIT License

    Visit original content creator repository https://github.com/softlab-unimore/landmark
  • salience-detection

    Salience Detection

    Python 3.6 CircleCI codecov

    The goal of this project is to detect salient entities in text documents.

    Input data

    The input files are stored in folders and have a JSON structure. Each JSON file contains one document. It should have a text field containing the document text. The documents used during training and testing should have an abstract field consisting of the abstract of the text and an entities field which is a list consisting of entities. An entity is a JSON object and should have an entity field and a salience field. The entity field is the most representative mention of the entity in the document. The salience field is true when the given entity is salient in the document and false otherwise.

    Example JSON file

    The following JSON file could be used as a training or testing document:

    {
      "text": "This text is about dogs. Dogs are animals. Cats are also animals.",
      "abstract": "Text about dogs.",
      "entities": [
        {
          "entity": "dogs",
          "salience": true
        },
        {
          "entity": "cats",
          "salience": false
        }
      ]
    }

    For evaluating a document, only the text field is required:

    {
      "text": "This text is about dogs. Dogs are animals. Cats are also animals."
    }

    The entities and salience information are determined by the model.

    Relevant Sentence Detection (RSD) model

    The first model is the relevant sentence detection (RSD) model. This model computes a relevance score for each sentence and reflects whether the sentence is relevant for the abstract of the text or not. The model is useful for text compression.

    Train the model

    In order to train the model, execute the following script:

    python train_rsd_model.py [train_path] [test_path] [out_path]
    

    The train_path argument should point to a directory containing input files used for training. The test_path argument should point to a directory containing input files used for testing and the out_path should be an empty directory in which the model files, log files and plot files should be stored. All model parameters are configurable. The parameters are explained by the help function which can be found by executing the following code:

    python train_rsd_model.py --help
    
    Visit original content creator repository https://github.com/kevin91nl/salience-detection
  • PaymentApp

    PaymentX

    Virtual Payment App like paytm which allows a user to transfer a virtual amount to various users. This project is build with concept of transactions in databases. Built with MERN stack.

    Here’s a more granular breakdown of your finance application, including requests, pages, models, and other details:

    1. Requests (API Endpoints):

    User Management:

    1. /api/v1/user/register (POST): Creates a new user account.
    2. /api/v1/user/login (POST): Authenticates a user and returns a token for secure access.
    3. /api/v1/user/ (GET): Retrieves the currently logged-in user’s profile information.
    4. /api/v1/user/ (PUT): Updates the information of the current user Logged In.
    5. /api/v1/user/bulk (GET): Retrives all the users that are currently associated with the application.

    Transfer Routes:

    Here the user authentication middleware is used to ensure only authenticated requests can access these routes.

    1. api/v1/transfer (POST) : Transfers money from one user to another.
    2. api/v1/balance (GET): Returns the account balance to the authenticated user.

    Technologies

    1. Javascript
    2. Nodejs
    3. Reactjs
    4. MongoDB
    5. zod
    6. Transcations in Databases
    7. ExpressJS framework
    8. JWT Authentication
    9. Tailwind CSS

    For Contributing

    Visit original content creator repository
    https://github.com/parthiv011/PaymentApp

  • Alfred-Workflow

    Alfred Workflow教程与实例

    小帽子Alfred作为macOS上的最佳效率软件应该没太大争议(排名),而其中最强大的部分即为Alfred 2.0推出的Workflow特性;其允许你将日常重复性的工作使用脚本语言(目前支持:bash, zsh, php, python, ruby, perl, osascript(AppleScript, JavaScript))封装起来,以Alfred作为统一的入口和呈现来使用,大大提高效率;本文将对其开发的一般流程进行讲述,并最终实现两个实例:

    • CDto: 打开Terminal并转到任意文件夹或文件所在目录,使用 bash+osascript 实现 点此下载

    • Effective IP: 查询本机和外网IP地址,解析任意URL和域名的IP地址,同时进行归属地和运营商查询,使用 python 实现 点此下载




    本文源代码地址:https://github.com/stidio/Alfred-Workflow,如果喜欢请Star!,谢谢!

    概述

    Alfred Workflow的整体架构,极度类似于Windows中的Direct Show,首先由一个Input开始,中间经过一堆filter,然后到一个Output结束,中间通过Pin连接,上一个Output Pin作为输入传递给下一个Input Pin,从而形成一个完整的Graph,而最终传递给Alfred做输出呈现的内容必须符合下面的形式:

    <?xml version="1.0" encoding="utf-8"?>
    <items>
        <item valid="yes">
            <title>10.0.2.11</title>
            <subtitle>45.76.65.119 美国新泽西州皮斯卡特维 choopa.com</subtitle>
            <icon>Info.icns</icon>
        </item>
    </items>

    Alfred上每一行显示对应一个item,如果显示多行,那就在items下放入多个item即可

    • valid 表现为可不可以选择,点击,再次传递
    • title 主标题
    • subtitle 副标题
    • icon 图标

    开发准备

    1. 使用[Option+空格]调出Alfred,输入alfred打开Alfred Preferences:

    2. 点击Workflows按钮,然后点击最下面的 + 按钮,创建一个Blank Workflow,按照提示填入信息:

      Bundle Id 作为该Workflow的标识为必填内容,如果不填或与其他重复,有可能造成其不能正常运行

    Workflow – CDto

    使用Terminal的一般步骤大概是运行Terminal,然后一路cd到目标文件夹后开始使用;虽然Finder有cd to插件,但也需要你一路点到指定文件夹后,才能调起来;虽然Alfred的Right Arrow按键里面有Open Terminal Here操作,但排在太后面了,打开的操作路径至少需要:Right Arrow -> 输入o -> [Command + 3]三步才能完成:

    作为一个需要频繁和Terminal交互的码农这完全不能忍,下面我们就利用Workflow做个一步到位的CDto神器

    1. 在Alfred Workflows的工作区点右键,选择菜单[Inputs -> File Filter],并按下图设置好,其他两个选项卡使用默认设置即可:

    2. 在刚才插入的[File Filter]上点击右键,选择菜单[Insert After -> Actions -> Run Script],并按照下图设置好,最下面的Escaping表示对指定字符进行转义,比如说:/Users/$a1,如果不对$转义,那外部会把$a1一起当做一个变量,而这个变量未定义也就是为空,传递进来的参数最终变成:/Users/,点此查看代码:

    Workflow – Effective IP

    现在我们使用Python来做个更复杂的例子,点此查看源码,具体分析见下图:

    我们基于Full-featured python library for writing Alfred workflows进行开发,具体的内容请参考前面的内容和官方教程, 这里我只对两个设置界面进行必要的解释:

    1. 主设置界面

      1. 直接输入ip无参形式是查询本机的本地和公网地址,有参形式是进行DNS解析,因此参数是可选的,需要设置为:[Argument Optional]
      2. 点击Run Behaviour按钮,进行运行行为设置
    2. 运行行为设置

      1. 如果输入发生变化,我们肯定是希望得到之后的结果,因此我们需要即时结束掉之前的查询
      2. 在输入过程中不进行查询,Alfred通过最后一个字符输入延迟来判断输入结束后才进行查询

    Workflow – UpdateAllNPM/UpdateAllPIP

    2018-05-01 新添两个Workflow

    • UpdateAllNPM 更新所有的全局Node.js模块
    • UpdateAllPIP 更新所有的Python模块

    其他事项

    1. 左边列表区域里点右键选择[Open in Finder]可以打开该Workflow的目录进行文件查看和编辑
    2. 点此可以调出调试窗口,查看调试信息

    参考资料

    神兵利器 — Alfred
    Alfred workflow 开发指南
    JavaScript for OS X Automation by Example
    Full-featured python library for writing Alfred workflows

    Visit original content creator repository https://github.com/stidio/Alfred-Workflow
  • Alfred-Workflow

    Alfred Workflow教程与实例

    小帽子Alfred作为macOS上的最佳效率软件应该没太大争议(排名),而其中最强大的部分即为Alfred 2.0推出的Workflow特性;其允许你将日常重复性的工作使用脚本语言(目前支持:bash, zsh, php, python, ruby, perl, osascript(AppleScript, JavaScript))封装起来,以Alfred作为统一的入口和呈现来使用,大大提高效率;本文将对其开发的一般流程进行讲述,并最终实现两个实例:

    • CDto: 打开Terminal并转到任意文件夹或文件所在目录,使用 bash+osascript 实现 点此下载

    • Effective IP: 查询本机和外网IP地址,解析任意URL和域名的IP地址,同时进行归属地和运营商查询,使用 python 实现 点此下载




    本文源代码地址:https://github.com/stidio/Alfred-Workflow,如果喜欢请Star!,谢谢!

    概述

    Alfred Workflow的整体架构,极度类似于Windows中的Direct Show,首先由一个Input开始,中间经过一堆filter,然后到一个Output结束,中间通过Pin连接,上一个Output Pin作为输入传递给下一个Input Pin,从而形成一个完整的Graph,而最终传递给Alfred做输出呈现的内容必须符合下面的形式:

    <?xml version="1.0" encoding="utf-8"?>
    <items>
        <item valid="yes">
            <title>10.0.2.11</title>
            <subtitle>45.76.65.119 美国新泽西州皮斯卡特维 choopa.com</subtitle>
            <icon>Info.icns</icon>
        </item>
    </items>

    Alfred上每一行显示对应一个item,如果显示多行,那就在items下放入多个item即可

    • valid 表现为可不可以选择,点击,再次传递
    • title 主标题
    • subtitle 副标题
    • icon 图标

    开发准备

    1. 使用[Option+空格]调出Alfred,输入alfred打开Alfred Preferences:

    2. 点击Workflows按钮,然后点击最下面的 + 按钮,创建一个Blank Workflow,按照提示填入信息:

      Bundle Id 作为该Workflow的标识为必填内容,如果不填或与其他重复,有可能造成其不能正常运行

    Workflow – CDto

    使用Terminal的一般步骤大概是运行Terminal,然后一路cd到目标文件夹后开始使用;虽然Finder有cd to插件,但也需要你一路点到指定文件夹后,才能调起来;虽然Alfred的Right Arrow按键里面有Open Terminal Here操作,但排在太后面了,打开的操作路径至少需要:Right Arrow -> 输入o -> [Command + 3]三步才能完成:

    作为一个需要频繁和Terminal交互的码农这完全不能忍,下面我们就利用Workflow做个一步到位的CDto神器

    1. 在Alfred Workflows的工作区点右键,选择菜单[Inputs -> File Filter],并按下图设置好,其他两个选项卡使用默认设置即可:

    2. 在刚才插入的[File Filter]上点击右键,选择菜单[Insert After -> Actions -> Run Script],并按照下图设置好,最下面的Escaping表示对指定字符进行转义,比如说:/Users/$a1,如果不对$转义,那外部会把$a1一起当做一个变量,而这个变量未定义也就是为空,传递进来的参数最终变成:/Users/,点此查看代码:

    Workflow – Effective IP

    现在我们使用Python来做个更复杂的例子,点此查看源码,具体分析见下图:

    我们基于Full-featured python library for writing Alfred workflows进行开发,具体的内容请参考前面的内容和官方教程, 这里我只对两个设置界面进行必要的解释:

    1. 主设置界面

      1. 直接输入ip无参形式是查询本机的本地和公网地址,有参形式是进行DNS解析,因此参数是可选的,需要设置为:[Argument Optional]
      2. 点击Run Behaviour按钮,进行运行行为设置
    2. 运行行为设置

      1. 如果输入发生变化,我们肯定是希望得到之后的结果,因此我们需要即时结束掉之前的查询
      2. 在输入过程中不进行查询,Alfred通过最后一个字符输入延迟来判断输入结束后才进行查询

    Workflow – UpdateAllNPM/UpdateAllPIP

    2018-05-01 新添两个Workflow

    • UpdateAllNPM 更新所有的全局Node.js模块
    • UpdateAllPIP 更新所有的Python模块

    其他事项

    1. 左边列表区域里点右键选择[Open in Finder]可以打开该Workflow的目录进行文件查看和编辑
    2. 点此可以调出调试窗口,查看调试信息

    参考资料

    神兵利器 — Alfred
    Alfred workflow 开发指南
    JavaScript for OS X Automation by Example
    Full-featured python library for writing Alfred workflows

    Visit original content creator repository https://github.com/stidio/Alfred-Workflow
  • Ai_CV_Analyse_NextJS

    Ai CV Analyzer

    CV Analyzer is a web application built with Next.js that analyzes uploaded CVs, providing insights and recommendations to improve alignment with job roles. The application includes key features like ATS readiness analysis, scoring, and tailored improvement suggestions.

    Image Placeholder Image Placeholder Image Placeholder

    Features

    • CV Upload & Analysis: Easily upload your CV for analysis.
    • ATS Compatibility: Analyze ATS readiness to ensure your CV meets applicant tracking standards.
    • Detailed Feedback: Receive actionable insights on skills, experience, and education.
    • Score Overview: View an overall score and breakdown by section.
    • Responsive Dashboard: Access a mobile-friendly dashboard to view your CV insights.
    • Dark Mode: Switch between light and dark themes for accessibility and comfort.

    Tech Stack

    Getting Started

    Follow these instructions to get a copy of the project up and running on your local machine.

    Prerequisites

    Make sure you have the following installed:

    Installation

    1. Clone the Repository:

      git clone https://github.com/madhurajayashanka/Ai_CV_Analyse_NextJS.git
      cd Ai_CV_Analyse_NextJS
    2. Install Dependencies:

      npm install
      # or
      yarn install
    3. Set Up Environment Variables:

      • Create a .env file in the root of the project and add your API keys:
        NEXT_PUBLIC_GEMINI_API_KEY=your_google_gemini_api_key

    Running the Application

    To run the development server:

    npm run dev
    # or
    yarn dev

    Open http://localhost:3000 in your browser to view the application.

    Usage

    1. Analyze CV: Upload a CV to receive a detailed analysis.
    2. View Dashboard: Access the dashboard to see the analysis results, including scores and recommendations.
    3. Download PDF: Save a PDF of the results for easy sharing or offline viewing.

    Contributing

    We welcome contributions to improve this project. To contribute:

    1. Fork the repository.
    2. Create a new branch for your feature or bug fix (git checkout -b feature-name).
    3. Commit your changes (git commit -m 'Add some feature').
    4. Push to the branch (git push origin feature-name).
    5. Open a Pull Request.
    Visit original content creator repository https://github.com/madhurajayashanka/Ai_CV_Analyse_NextJS
  • qvm-pass

    qvm-pass

    qvm-pass is a frontend for pass running in a vault VM. It is an implementation of split-pass in the spirit of split-gpg and split-ssh using the qrexec RPC interface of Qubes OS. qvm-pass aims to provide the same user interface as the original pass command. However, the pass git subcommand gets blocked to avoid execution of dangerous operations.

    Consider combining qvm-pass with split-gpg.

    This code was written in a very short time frame and hasn’t had any peer review. Use at your own risk!

    Installation

    Location: AppVM for qvm-pass

    1. Clone the repository

    git clone https://github.com/mtdcr/qvm-pass

    2. Install pass script to ~/.local/bin

    pipx install ./qvm-pass

    3. Copy qrexec service to TemplateVM for pass-vault

    qvm-copy qvm-pass/qubes-rpc/qubes.PasswordStoreWrite

    Location: Dom0

    4. Install qrexec policies

    Create policy files:

    • /etc/qubes-rpc/policy/qubes.PasswordStoreRead
    • /etc/qubes-rpc/policy/qubes.PasswordStoreWrite

    Examples can be found in qubes-rpc/policy.

    Location: TemplateVM for pass-vault

    5. Install qrexec service for write operations

    sudo install -m755 ~/QubesIncoming/*/qubes.PasswordStoreWrite /etc/qubes-rpc/

    6. Create symlink for qrexec service for read operations

    sudo ln -s qubes.PasswordStoreWrite /etc/qubes-rpc/qubes.PasswordStoreRead

    Configuration

    qvm-pass reads the name of the vault VM from ~/.config/qvm-pass/qube. It defaults to pass-vault.

    Supported environment variables and their default values

    • PASSWORD_STORE_CLIP_TIME=45
    • PASSWORD_STORE_GENERATED_LENGTH=25
    • PASSWORD_STORE_X_SELECTION=clipboard

    Alternatives

    • qubes-pass – It uses a slightly modified command-line interface compared to the original pass command.

    Visit original content creator repository
    https://github.com/mtdcr/qvm-pass

  • posty-starter-plugin

    Posty Starter Plugin

    An opinionated starter plugin for WordPress.

    Table of Contents

    Installation

    Clone or copy the contents of the repository, then run npm install or yarn install to get started.

    There’s a few placeholders that need to be replaced. Please note that these are case-sensitive. For example. if your plugin is named lion-king-quote-generator, you’d rename like this:

    Original Replacement Used For
    posty-starter-plugin.php lion-king-quote-generator.php The base plugin file
    Posty_Starter_Plugin Lion_King_Quote_Generator PHP classes namespace
    posty-starter-plugin lion-king-quote-generator Textdomain and block name prefix
    POSTY_STARTER_PLUGIN LION_KING_QUOTE_GENERATOR Constants
    postyStarterPlugin LionKingQuoteGenerator JavaScript l10n variable*

    *This is the $object_name variable when localizing a script in the Assets class.

    Development

    Run npm run start to start developing. Webpack will automatically process style and script changes.

    Build

    Run npm run build to compile and minify all assets.

    Features

    Posty Starter Plugin has a bunch of features that enable you to get productive right from the start.

    Custom Post Types

    To register a new custom post type, you need to extend the Custom_Post_Types/Base class like so:

    class Event extends Base {
        const NAME = 'posty-event';
    
        /**
         * Register the custom post type.
         */
        public static function register() {
            $options = [
                'slug' => __('event', 'posty-starter-plugin'),
                'singular' => __('Event', 'posty-starter-plugin'),
                'plural' => __('Events', 'posty-starter-plugin'),
                'args' => [
                    'menu_icon' => 'dashicons-calendar'
                ]
            ];
    
            parent::register_cpt(self::NAME, $options);
        }
    }

    This creates the posty-event post type. The slug, singular and plural options are mandatory, and the args option allows you to overwrite any option passed to register_post_type.

    You can also add custom labels like so:

    $options = [
        'slug' => __('event', 'posty-starter-plugin'),
        'singular' => __('Event', 'posty-starter-plugin'),
        'plural' => __('Events', 'posty-starter-plugin'),
        'labels' => [
            'add_new' => __('Add a new event', 'posty-starter-plugin')
        ],
        'args' => [
            'menu_icon' => 'dashicons-calendar'
        ]
    ];

    The nice thing about registering custom post types like this is that you can extend these classes with any kind of functionality related to the post type. For example, you might want the ability to get the latest three events. You could add it like this:

    /**
     * Get the latest events.
     *
     * @return WP_Post[]
     */
    public static function latest() {
        return get_posts([
            'post_type' => self::NAME,
            'posts_per_page' => 3
        ]);
    }

    Then, in your code you can use this function to easily display the latest three events:

    use Posty_Starter_Plugin\Custom_Post_Types\Event;
    
    $events = Event::latest();
    
    foreach ($events as $event) {
        echo $event->post_title;
    }

    A similar method could be used to implement functionality related to a single event. For example, let’s say you have a meta field event_ticket_price that contains the price of an event. You could add this code to your Event class to easily obtain this price:

    /**
     * Get the ticket price of an event.
     *
     * @param WP_Post|int $event
     * @return string
     */
    public static function ticket_price($event = null) {
        $event = get_post($event);
    
        return get_post_meta($event->ID, 'event_ticket_price', true);
    }

    use Posty_Starter_Plugin\Custom_Post_Types\Event;
    
    $ticket_price = Event::ticket_price();
    
    echo $ticket_price;

    By adding $event = get_post($event), the function defaults to the current event, but also allows you to get the price of a specific event by passing the post ID or a WP_Post object.

    Taxonomies

    Taxonomies work almost exactly the same as custom post types. One difference is that you can also pass the object_type option to link the taxonomy to a specific post type. See the Event_Category class for an example.

    Assets

    The Assets class takes care of registering styles and scripts. The @wordpress/scripts package is used to automatically list the dependencies needed for each scripts.

    The code in editor/index.js only runs in the Block Editor, and the code in frontend/index.js only runs on the frontend of the site. The same principles apply to editor.css and frontend.css

    Note: if you want to use Sass instead of CSS, install and add sass-loader to webpack.config.js.

    Blocks

    A big focus of the Posty Starter Plugin is making it as easy as possible to register blocks. All blocks can be found in the src/js/editor/blocks folder and are initialized in src/js/editor/index.js. To render a server-side block, add a template file with the same name as the block to the templates/blocks folder.

    For more information on developing blocks, please refer to the Block API Reference.

    Helpers

    In helpers.php, you can find a collection of custom helper functions as well as add your own.

    classes

    classes is similar to the very popular classNames package for JavaScript, and allows you to conditionally add classes to an HTML element. It’s based on classnames-php.

    Use it like this:

    Posty_Starter_Plugin\classes('foo'); // 'foo'
    Posty_Starter_Plugin\classes(['foo' => true]); // 'foo'
    Posty_Starter_Plugin\classes('foo', ['bar' => false, 'baz' => true]); // 'foo baz'
    Posty_Starter_Plugin\classes(['foo', 'bar' => true]) // 'foo bar'
    
    // Falsy values get ignored
    Posty_Starter_Plugin\classes('foo', null, 0, false, 1); // 'foo 1'

    get_template and get_template_var

    These two functions allow you to render template parts from the templates folder with custom parameters. To demonstrate how this works, here’s an example. Let’s say you have a template part, templates/hello.php, that looks like this:

    $name = 'Phil';
    
    echo "Hello, my name is {$name}.";

    This would output Hello, my name is Phil. To render this template part, you can use the get_template helper function:

    echo Posty_Starter_Plugin\get_template('hello');

    However, you might also want to want to make the name dynamic. To allow this, get_template accepts an array of parameters:

    echo Posty_Starter_Plugin\get_template('hello', [
        'name' => 'Lindsay'
    ]);

    To use the dynamic name, you’d change templates/hello.php to this:

    $name = Posty_Starter_Plugin\get_template_var('name');
    
    echo "Hello, my name is {$name}.";

    License

    GPL 3.0

    Visit original content creator repository
    https://github.com/posty-studio/posty-starter-plugin