Post-process/filter all textilizable fields in Redmine via plugin? - redmine

I am attempting to write a Redmine plugin which further filters textilizable fields (issue description, updates, wiki content, etc.).
I've leafed around the plugin documentation but did not really find a good place to start. The view hooks seem to allow you to inject content at pre-defined injection points. Nothing really stood out toward creating a filter for textilizable content.
The most straightforward way is to hack the code in application_helper.rb and create your own filter function along the same lines of the :parse_inline_attachments, :parse_wiki_links, :parse_redmine_links. However, I do not see a good way of inserting that in a plugin without monkey patching the entirety of textilizable(*args).
Am I missing something obvious here?

One possible way, here: http://www.redmine.org/boards/3/topics/33949
This board topic mentions the caveats associated with view hooks (mentioned above) and offers a workaround or two that lets you change content by overriding views.

Related

How to make editable fields in frontend for Django objects

I need to make objects editable in frontend by clicking on it and enable a form field to edit the text. i.e. in a ToDo-list which tasks can be edited by clicking on the task like shown in the following graphics:
I am working with Django 2.x and unfortunately, I'm a little inexperienced.
Is it a good practice to realize this with REST API and/or Angular/React?
I would be glad about a few experiences, how something is feasible.
I have found a good solution to implement the desired functionality with Jeditable
https://github.com/NicolasCARPi/jquery_jeditable

Django CMS custom file rendering - extra plugin necessary?

I want to allow the users of a django-CMS to edit the background image in one of my CMS_TEMPLATES using the filer admin. How can I achieve this in a clean way, but with minimum of code and database tables?
My current solution is to (mis-)use the cmsplugin_filer_file by writing a custom template for it. The disadvantage is that I'll maybe want to use this plugin in a different way one day, and I think one cannot have several templates for one plugin.
A cleaner alternative would be to write a custom cmsplugin with a model containing a FilerFileField and nothing else. But this will require more lines of code and will create a new database table.
Is there a better solution which I didn't think of yet?
I hope, this question can be answered, not just discussed...
Maybe have a look at page extensions. This a new 3.0 feature:
http://django-cms.readthedocs.org/en/develop/extending_cms/extending_page_title.html

Stackoverflow like tag system form for django?

What I am trying to create is a site for resources. Basically, you add resources such as books and videos via links. Now, with any resource site that caters to a variety of resources, you need to tag them in order to understand what kind of resource you are using.
For example, if you make notes on something like Chemistry or key points from a talk on lets say "Django", then these are text documents. Thus you would want them inside a TEXT TAG.
So, when you are making a form for this kind of thing, what form field would you use? For example, by knee-jerk approach is to simple make a text area field, and then separate the different tags via comma. Now, this can be prone to many problems, I'd just like to know what is the best approach to take to solving this problem? Basically, an easy way to validate the data input? Would forms.ChoiceField be the best approach to the problem or is there something else that is superior?
https://www.djangopackages.com/grids/g/tagging/ is your best bet, most specifically https://github.com/alex/django-taggit. If you want to run your own tagging system, take a look at the source code for some ideas.
EDIT: The easiest way to display this in a form would be to use a ModelMultipleChoiceField. This allows you to select multiple tags for a single resource, and handles server-side validation and conversion to the actual Tag instances. However, I think most people would agree this option looks hideous, and it is certainly not user-friendly if there is a large amount of possible tags.
If you're using jQUery, another option is to use Django_select2. This is what I have personally used in a similar situation, and it handles a large amount of possible tags very well. Django_select2 is a thin wrapper around jQuery's Select2 plugin, with a bit of added functionality (most notably the AutoView and AutoModelSelect2Field). This provides a hybrid between a text field and a select list, allowing you to search all tags and easily select multiple tags. See http://ivaynberg.github.io/select2/ for examples of what you can achieve.

Are workflow comments customizable?

Does anyone know of any way to customise the Workflow Comments box that appears in Sitecore if you enable the "comments" option?
I'm looking to extend this a little ... but can't see this referenced in any sitecore javascript or shell files - I'm guessing I will need to build a custom dialog in its entirety to implement the functionality I want, but not 100% where to start!
We ended up putting a solution in place that, broadly, composes of a custom action, containing the relevant form that we need. The information that the user submitted was then parsed, and passed to the workflow as comments (this particular workflow command was hidden from users, so they had to go through our custom one).
Not ideal, but works!

Django strategy for automatically suggesting matching content

I'm looking at porting a custom-written PHP CMS into Django. One of the features the CMS currently has is an image upload function. I write an article, tag it with information, then choose a photo for it. If the system has any photos which have been added to articles with tags in common with the new one, it will suggest the photo for that article too. If there are no matches then a new image can be added.
In case this doesn't make sense, let's say I tag an article as Bruce Springsteen, The Beatles and Led Zeppelin. Next time I add an article with the tag The Beatles, it should suggest I use the image added for the first article.
What would be the best Django-applicable way to implement this? I've looked at the Photologue app and have integrated it, and I know it has tagging support (the problem here is that I'm using django-taggit, whereas Photologue supports django-tagging). One approach could be simply building it myself -- when a user uploads an article, I run a hook after they save it to associate the tags with the image. I'm just not sure how to then autosuggest an image in the admin tools based on that info.
Any ideas/approaches greatly appreciated.
This is almost certainly something you're going to have to build yourself. Django has a moderate number of libraries out there (that you've clearly already found). Unlike other solutions, it doesn't have a lot of things that get you 100% to your desired solution (whereas something like Drupal might get you 100% of the way there).
What you will probably need to do (at a high level) is something like this:
Create an AJAX view that takes the current tags as an argument and does a query on the existing posts to see what tags match and returns images from those posts.
Use jQuery/javascript on your view to call your AJAX view on the page as tags are added
Use jQuery to update a <div> on your page and show all the images that your view returned
Here is a similar example that might help get you started.
You might look into django-ajax as a helper library for your requests, but it definitely isn't necessary.
The hook between the your image module and any other django module can be implemented using django's contenttypes framework which also provides some useful instance methods for returning related/hooked objects.