Abbreviations and acronyms plugin

thanx on great plugin.
Unfortunately not working for me.
I am on 1.7.0.beta1 version
I did install it only on containers/app.yml
without editing settings.

It is installed and activated on admin menu.

When I type IMMO nothing happns.

when I type <abbr>IMMO</abbr> i get question mark over word but nothing happens

There is no network calls also there no erros in chrome chonsole

1 Like

Is this still working @tgxworld?

1 Like

This plugin is definitely broke. Dialects work differently since the completion to ES6
https://github.com/PoloGT/abbreviation-discourse-plugin/blob/master/assets/javascripts/abbreviations_dialect.js

4 Likes

moving to #plugin:broken-plugin @BlackSheep please let us know once this is working again!

6 Likes

We are shipping this to a customer, so we have to fix it @sam @tgxworld

5 Likes

So i have this code in a file called abbreviations.js.es6

import { registerOption } from 'pretty-text/pretty-text';

registerOption((siteSettings, opts) => {
  opts.features['abbreviations'] = !!siteSettings.abbreviations_plugin_enabled;
});


function abbreviate(text) {
  var siteSettings = Discourse.SiteSettings;
  if (siteSettings.abbreviations_plugin_enabled) {
      //blabla.............
  }
  return text;
}

export function setup(helper) {
    helper.addPreProcessor(abbreviate);
}

The line

var siteSettings = Discourse.SiteSettings;

is giving me some headaches. Can someone give me some advice on how to reach Discourse.SiteSettings from there?
It works in the client, (i.e the preview window), but when I try to save the message that line gives an error, there is no way to save the message.

4 Likes

I don’t think you need that. As the opts.features['abbreviations'] = !!siteSettings.abbreviations_plugin_enabled; handles that for you.

2 Likes

@BlackSheep You were getting really close :slight_smile:

I submitted a PR here so you can have a look how site settings can be accessed via the new API.

https://github.com/PoloGT/abbreviation-discourse-plugin/pull/2/files

9 Likes

That is great, thank you @tgxworld ! . helper.getOptions() was what I was looking for. Silly me :smiley:

Your solution is working for me in my development rig. I already merged it in the repository so anyone can use it, but I am going to make it ‘backwards compatible’ later on, so the plugin works in an old installation I have (EDIT: already done).

@sam, as far as i am concerned the plugin works again

@adopilot, thanks for noticing!

8 Likes

It’s not working and misleading with mobile and touch devices. When you touch it, its select the dot underlined text (like a link for nothing).

1 Like

As far as I know, the abbr tag doesn’t work in mobile devices. You are right, i should put a css media query so it doesn’t underline the acronym in mobile devices.

3 Likes

Or, if possible, you could change the mobile behavior so it will toggle viewing when touched (instead of hover, you could simulate a click to activate it). I hope it will be possible. Since mobile & touch devices are widely used!

1 Like

I’ve added touch capability to this plugin with some custom script and css:

With thanks to Scott Asbach for the original code

<head>:

<script type="text/javascript">
    /**
 * touchHover.js
 *
 * Create tooltips on mouseover or on click (for supporting touch interfaces).
 * 
 * @author C. Scott Asbach
 */

$(document).ready(function() {	
	
	/**
	 * store the value of and then remove the title attributes from the
	 * abbreviations (thus removing the default tooltip functionality of
     * the abbreviations)
	 */
	$('abbr').each(function(){		
		
		$(this).data('title',$(this).attr('title'));
		$(this).removeAttr('title');
	
	});

    /**
	 * when abbreviations are mouseover-ed show a tooltip with the data from the title attribute
	 */	
	$('abbr').mouseover(function() {		
		
		// first remove all existing abbreviation tooltips
		$('abbr').next('.touchtooltip').remove();
		
		// create the tooltip
		$(this).after('<span class="touchtooltip">' + $(this).data('title') + '</span>');
		
		// position the tooltip 4 pixels above and 4 pixels to the left of the abbreviation
		var left = $(this).position().left + $(this).width() + 4;
		var top = $(this).position().top - 4;
		$(this).next().css('left',left);
		$(this).next().css('top',top);				
		
	});
	
    /**
	 * when abbreviations are clicked trigger their mouseover event then fade the tooltip
	 * (this is friendly to touch interfaces)
	 */
	$('abbr').click(function(){
		
		$(this).mouseover();
		
		// after a slight 2 second fade, fade out the tooltip for 1 second
		$(this).next().animate({opacity: 0.9},{duration: 2000, complete: function(){
			$(this).fadeOut(1000);
		}});
		
	});
	
	/**
	 * Remove the tooltip on abbreviation mouseout
	 */
	$('abbr').mouseout(function(){
			
		$(this).next('.touchtooltip').remove();				

	});	
	
});
</script>

mobile CSS:

.touchtooltip {
	position:absolute;
	color:white;
	background-color: #FF9999;
	font-size: smaller;
	padding: 4px 8px;
	box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.1);
}

abbr {
    border-bottom: 1px black dotted;
}
8 Likes

Is there a way to get this plugin to recognize acronyms directly followed by a colon (or some other punctuation for that matter)?

Example: I have defined BTW as “By the way” in the plugin settings, but when I write “BTW: xyz” in a post, it is not rendered as an acronym whereas “BTW : xyz” is.

1 Like

Uh, you should be triggering that code on post render, not on document ready.

I consider myself below amateur grade at coding, so the fact it even works at all amazes me :smiley:

3 Likes

Very weird situation: I posted a topic with an image in category A. When I move the topic to category B, the image in the post was no longer rendered but instead, the image path was displayed (just like in the editor). Trying to upload the same or another image to that post leads to the same result. What’s more, uploading images to posts is now broken on the entire site. Images seem to upload fine but only the path is displayed.

I tried rebuilding HTML but to no avail.

Context:

  • the image was embedded as a float using [floatl] ... [/floatl]
  • I have the translator plugin activated and the text of the post was in a different language than both the site and my user locale
  • the category name of category B contains an ampersand (&) though the slug is a single word

This is so weird, I don’t even know where to start debugging. Or to get things working again (do I need to rebuild for this?)

UPDATE: there is no error in the error logs and there are no dead jobs in /sidekiq

UPDATE 2: OK, I found the black sheep: it was @BlackSheep’s abbreviation plugin. When I deactivated it, things worked again.

Maybe it has something to do with the fact that I have “app” defined as an abbreviation in the plugin’s settings and the word app appeared in that post that cause the trouble?

2 Likes

I’m getting a JavaScript error which I believe originates from the abbreviations plugin:

Looks like a similar issue (involving Discourse.dialect_deprecated) to what I had with the discourse-solved plugin - @eviltrout fixed it with this commit

https://github.com/discourse/discourse-solved/commit/9b1ebaae912b7ce950f14cd96348a2e1dd4f7c3b

So probably a similar solution required here.

6 Likes

Since @BlackSheep is apparently no longer maintaining this plugin, it would be great if someone would fork it and make the necessary adjustments. :slightly_smiling_face:

3 Likes