Abbreviations and acronyms plugin


(cpradio) #28

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


(Alan Tan) #29

@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.


#30

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!


(EW 👌) #34

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).


#35

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.


(EW 👌) #36

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!


(Tom Newsom) #37

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;
}

(Christoph) #38

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.


(Kane York) #39

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


(Tom Newsom) #40

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


(Christoph) #41

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?


(Chris Beach) #42

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


(David Taylor) #43

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

So probably a similar solution required here.


Discourse.Dialect is undefined error
(Christoph) #44

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:


(Ridha) #45

Hi, is this plugin still a broken plugin?

I found this in GitHub and I guess this plugin is maintain by Discourse as an official plugin.
Thanks


(Sam Saffron) #46

Discourse footnote is officially supported


(Freso) #47

I’d like to echo @iidbae’s question. @sam’s answer is not really an answer. “Discourse footnote” solves a different problem to what this plugin is/was handling.


(Sam Saffron) #48

It solves a similar problem.

Porting Linkify words in post to act like this plugin should be fairly trivial. I recommend someone gives it a shot.


(Freso) #49

I gave it a shot and made this:

It is currently running on the MetaBrainz Discourse installation:

I’d post about it in #theme but @sam needs to grant me privileges first. :slight_smile:


(Freso) #50

Theme component posted here: