Coder Social home page Coder Social logo

snippets's Introduction

Snippets plugin for MantisBT

Copyright (c) 2010 - 2012 Amethyst Reese - https://noswap.com
Copyright (c) 2012 - 2021 MantisBT Team - [email protected]

Released under the MIT license

See the Changelog.

Description

Define snippets of text that can be easily pasted into text fields.

Requirements

The plugin requires MantisBT version 2.3 or higher.

If you need compatibility with older releases of MantisBT, please use legacy versions of the plugin, as per table below:

MantisBT version Plugin version
1.3 1.x (master-1.3.x branch)
1.2 0.6

Installation

  1. Download or clone a copy of the plugin's code.
  2. Copy the plugin (the Snippets/ directory) into your Mantis installation's plugins/ directory.
  3. While logged into your Mantis installation as an administrator, go to Manage -> Manage Plugins.
  4. In the Available Plugins list, you'll find the Snippets plugin; click the Install link.
  5. In the Installed Plugins list, click on the Snippets plugin to configure it.

Usage

Managing Snippets

Once the plugin is installed and configured, you need to define at least one Snippet, otherwise the selection list will not be shown.

  • Global snippets can be managed from Manage > Manage Plugins.
  • User-specific snippets can be managed from My Account > My Snippets.

The following placeholders are supported in the Snippet's text; they will be replaced by the corresponding contents when inserted:

Placeholder Description
{user} your username
{reporter} the bug reporter's name
{handler} the bug handler's name
{project} the project name

Create new Snippet screenshot

Using Snippets

Each configured text field will have a selection list above it, which can be used to pick the desired Snippet.

Select Snippet screenshot

Once selection is made, the Snippet's text will be inserted in the field at the current position. If text is currently selected, the Snippet will replace the selection.

Snippet inserted screenshot

By default only the Bug Note field is configured to use Snippets. Other text fields (Description, Steps To Reproduce as well as Additional Information) can be setup to use Snippets via configuration page Manage > Global Snippets > Configuration.

REST API

The following public API endpoints can be used to manage Snippets.

Base URL is https://example.com/mantisbt/api/rest/plugins/Snippets

GET /search

Search for and return a list of Snippets available to the user.

Parameters:

  • query: Return only Snippets having a title or contents matching the given search string. Default is no filtering.
  • limit: Limit the number of Snippets returned. Default is 10.

GET /

Retrieve the list of Global or the user's Personal Snippets.

Parameters:

  • global: 1 for global Snippets, 0 for personal Snippets. Default is 0.

POST /

Create a new snippet. Provide data as JSON body

{
  "name": "Snippet's name",
  "text": "Snippet's body",
  "global": true
}

If global is false, then a personal Snippet will be created for the user calling the API endpoint.

PUT /{SnippetId}

Update an existing Snippet. Note that global state cannot be changed.

{
  "name": "New name",
  "text": "New body"
}

DELETE /{SnippetId}

Delete snippet.

Support

The following support channels are available if you wish to file a bug report, or have questions related to use and installation:

snippets's People

Contributors

amyreese avatar atrol avatar dregad avatar obones avatar syncguru avatar tporadowski avatar vboctor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

snippets's Issues

Snippets Plugin - update error

The snippets plugin is recognized by mantis but shows as being out of date. When clicking the update button the following error is shown on the page:

"APPLICATION ERROR #2503
Upgrading the plugin schema failed in block #0.
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section."

When clicking the plugin name to try to configure it, the following error is shown:

"APPLICATION ERROR #2505
The "Snippets" plugin needs to be upgraded before you can access this page.
Please use the "Back" button in your web browser to return to the previous page. There you can correct whatever problems were identified in this error or select another action. You can also click an option from the menu bar to go directly to a new section."

snippets_error

{handler} and {project} not working in Reminder textarea

Hi,

  • The tag {project} it does not show the current project but it is showing All Projects

  • The tag {handler} not working as expected, the tag as it is printed in a textbox.

Note: In Note, Description, Steps To Reproduce, Additional Information is working fine as expected but only in Reminder isn't working.

Kindly refer the below-attached screenshot
PM tool

snippets dropboxes do not appear

After version 2.23.0 update, the snippets disappeared through the text box.
No problem in the plugin settings section. but the selection snippets dropboxes do not appear where the text is written.
Can you help?

Snippets configuration does not honor project level access.

Snippets configuration does not honor project level access. Configuration settings will only take into consideration a users global access and not allow access to snippets depending on their project level access. i.e. If snippets is set to be usable by developers and above and a user has 'viewer' access globally and 'developer' access for a specific project, they will
not be able to access snippets at all.

Ideally, the user should be able to access snippets in specific projects where they have the relevant permitted access level.

Hide Snippets selection list when none are available

As mentioned in #40, when there are no defined Snippets for user or globally [...] the Snippets dropdown is visible with one entry --. The expected behavior should be to not show the Snippets dropdown

This should have been fixed in #24, but apparently the fix was incorrect or incomplete.

Config Page should redirect to originating page

Currently, when the user clicks the Update button, the config page does not redirect after saving changes.

Since the Configuration can be reached both from the Global Snippets and from the Manage Plugin pages, it should go back to the page it came from.

In Chrome Has bugs

hi, In chrome unlike internet explorer is not enabling pluguin, what add-on do I need to enable?

thanks

Plugin folder structure

Would it be possible to move all files of this repo to a subfolder called "Snippets"?

We are using an automated process to deploy mantis and the most useful plugins.
The snippets repo is the only plugin that is different from all other plugins we pull from github, so having a unified structure would be fantastic.

Thank you!

Improvement to UI

Hi, I wanted to make a couple of suggestions for the snippet plugin that I think would improve UI experience.

  1. I find it difficult to find the snippet I want when we have many snippets. A simple fix would be to have snippets ordered alphabetically but ideally we'd love to see a way to define order and group snippets.
  2. Would be great to have the section for creating snippets at the top of the page rather than the bottom. If you have a lot of snippets, it's alot of scrolling if you want to add a new one. Same goes for the action drop down box and 'Go' button. Perhaps provide this option at the top of the snippet list as well as the bottom.

thanks,
Sandra

MantisBT install page included instead of plugin-specific install functions

When the plugin's schema function executes, the current working directory is that of the parent script, i.e. the one which calls plugin_needs_upgrade(), usually via plugin_init_installed() in core.php.

When said parent script is one of MantisBT's admin scripts, typically the index page, this results in MantisBT's install.php file to be included instead of the plugin's, resulting in the page displaying a (non-functional) install page on top of its actual contents as shown in the screenshot below

image

Regression introduced in 2.3.0 by 20484c1.

Apache error `client denied by server configuration`

This following error shows up in /var/log/apache/errors.log when there are no defined Snippets for user or globally. In such case, the error is generated and the Snippets dropdown is visible with one entry --. The expected behavior should be to not show the Snippets dropdown and not generate an error.

[Tue  May 01 00:54:21.066773 2018] [authz_core:error] [pid 20615] [client  172.31.34.65:45273] AH01630: client denied by server configuration:  /.../www/plugins/Snippets/data,  referer: https://mantisbt/view.php?id=761

Can't retrieve snippets data from REST API if URL rewriting is not working

Snippets plugin doesn't work in my site.
I can see the Snippet menu on the Manage page, but I cannot see the snippet option on the 'View issues' page. My issue seems like the #23

I installed as below:

  • Snippets ver : 2.1.0 / Mantis BT ver : 2.9.0 / PHP ver : 7.1.12

Is there anything that I need to do?

Console error log

jquery-2.2.4.min.js:4 GET http://...api/rest/plugins/Snippets/data/29655 404 (Not Found)
send @ jquery-2.2.4.min.js:4
ajax @ jquery-2.2.4.min.js:4
n.(anonymous function) @ jquery-2.2.4.min.js:4
getJSON @ jquery-2.2.4.min.js:4
SnippetsInit @ plugin_file.php?file…pets/snippets.js:88
(anonymous) @ plugin_file.php?file…ets/snippets.js:125
i @ jquery-2.2.4.min.js:2
fireWith @ jquery-2.2.4.min.js:2
ready @ jquery-2.2.4.min.js:2
J @ jquery-2.2.4.min.js:2

plugin_file.php?file…pets/snippets.js:91 Error occured while retrieving Snippets
(anonymous) @ plugin_file.php?file…pets/snippets.js:91
i @ jquery-2.2.4.min.js:2
fireWith @ jquery-2.2.4.min.js:2
z @ jquery-2.2.4.min.js:4
(anonymous) @ jquery-2.2.4.min.js:4
XMLHttpRequest.send (async)
send @ jquery-2.2.4.min.js:4
ajax @ jquery-2.2.4.min.js:4
n.(anonymous function) @ jquery-2.2.4.min.js:4
getJSON @ jquery-2.2.4.min.js:4
SnippetsInit @ plugin_file.php?file…pets/snippets.js:88
(anonymous) @ plugin_file.php?file…ets/snippets.js:125
i @ jquery-2.2.4.min.js:2
fireWith @ jquery-2.2.4.min.js:2
ready @ jquery-2.2.4.min.js:2
J @ jquery-2.2.4.min.js:2

snippet2

snippet

Provide easy access to Edit/Delete option for snippets.

Edit and delete options for existing snippets should be button options displayed next to each snippet rather than requiring a selection checkbox and scrolling to the bottom of the screen for dropdown box selection and clicking Go. Or you can replicate the dropdown box and Go at the top of the table but preference is for buttons next to the snippet itself.

Page title missing

The page title is not set for the following pages

  • My / Global Snippets
  • Config Page

Order created snippets

Have snippets ordered alphabetically to allow easier navigation. Or provide alternate way to manage snippets (grouping, categories with expand/collapse options perhaps).

Snippets stopped working since update to Mantis 2.25.0

All Snippets dropdowns are gone.

Opening plugin configuration page reveals:

APPLICATION ERROR #2505

Das Plugin „Snippets“ muss aktualisiert werden, bevor Sie auf diese Seite zugreifen können.

Bitte benutzen Sie die „Zurück“-Taste Ihres Browsers, um auf die vorhergehende Seite zurückzukehren. Dort können Sie den hier angezeigten Eintrag korrigieren oder eine andere Aktion ausführen. Über das Menü können Sie auch direkt zu einer anderen Aktion wechseln.

Use REST API instead of xmlhttprequest

The xmlhttprequest is being deprecated in MantisBT v2.3.0. Hence, snippets should publish its own REST APIs via the new framework and leverage that to power its functionality.

bug in MantisBT 2.21.0

Hello, in the new version of mantisbt 2.21 the plugin does not work, it does not allow to use the templates, Placeholder is not activated

Carlos Felipe

Tooltip not shown on snippets list page

When the list of snippets is long enough so that the Create Snippet form is not visible without scrolling down, then the tooltip is not visible.

It seems like the calculation of the Y-position is incorrect, seems like a bug of the simpletip jquery plugin.

Using for description

Hi,
I have installed Snippets Plugin into my mantis installation and everything is working as I wish, except one....I can use snippets for bug notes only, but I would like to use them for new bug description as well....Could anyone help me with the code modification? Thanks a lot....

Real names instead of user names used for placeholders

Placeholders for users are replaced by the real name instead of the user name if the following configuration is used and the access level of the current user is >= $g_show_user_realname_threshold

$g_show_realname = ON;
$g_show_user_realname_threshold = DEVELOPER;

When using such a snippet, real names are published to any user, even those who are not allowed to view real names.

{user} show {handler}

Hi, the tag
{user}

it does not show the username but it is showing the user assigned

Mantisbt 2.14.0
Snippets 2.2.5

Saludos, Carlos Felipe

Hang Chrome while loading snippets

We've found out that the Snippets plugin hangs Chrome for all the time it loads the snippets with Ajax.

This is OK if you have only a few snippets and working with a fast connexions but we have tons of snippets and some of my colleagues are sometimes working over a slow connection and Mantis bugs pages can take up to 15 seconds to load.

We have other plugins with Ajax loading and they do not hang the browser while loading, even if it takes several seconds to load.

I haven't tested other browsers.

To reproduce the issue:

  • add tons of snippets in Mantis, probably with a script or SQL query
    • test from a slow connection or simulate a slow connection with a sleep in the foreach loop of pages/snippet_list.php

Use more descriptive place holders

How about using the following place holders, but still support the old ones for backward compatibility.

{user} instead of %u
{reporter} instead of %r
{handler} instead of %h
{project} instead of %p

Re-locate Create snippet section

To prevent having to scroll through a long list of existing snippets, the create snippet section should be moved to the top of the page.

After Upgrading to 2.3.1 the plugin's upgrade function crashes

after upgrading the plugin, in the plugin overview it is said, that it needs to be upgraded. when clicking the upgrade button there is an Error in Block #1

when deactivating the line 174 in Snippets.php it doesn't need that upgrade and the plugin works back again.

it seems that the plugin's init function is not executed to include the install_functions.php

using mantisbt 2.25.0 (upgraded from mantis 2.24.1)

qTip2 library throws 'Source map error' in browser console

Source map error: request failed with status 404
Resource URL: http://localhost/mantis/plugin_file.php?file=Snippets/jquery.qtip.min.js
Source Map URL: jquery.qtip.min.map

https://developer.mozilla.org/en-US/docs/Tools/Debugger/Source_map_errors

The jquery.qtip.min.css file's last line points to the source map.

//# sourceMappingURL=jquery.qtip.min.map

Since we don't really need this for production use, it should be removed from the bundled js.

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.