ElkArte Community

Extending Elk => Addons => Topic started by: emanuele on June 05, 2016, 05:09:53 pm

Title: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 05, 2016, 05:09:53 pm
Okay, I re-read the topic because honestly I had forgot almost everything.
So, at the moment the situation is:
1) there is an addon that allows to post "follow" URLs based on permissions,
2) the need is an addon that has a white-listing feature based on the domain.
Correct?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on June 06, 2016, 07:00:06 pm
Thank you emanuele, is correct what you are saying. Will this addon use custom bbcode or it will be invisible?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 08, 2016, 01:20:23 pm
Have a look at the attached.

Maintains the permission things (sorry, too lazy to remove it) and adds on top of it a white-listing and the exclusion from the "nofollow rule" of internal links.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on June 09, 2016, 05:54:17 pm
Thank you Emanuele, I will try it  8)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on June 24, 2016, 05:30:42 am
I did not forget about this, I've been out in the last 2 weeks ;) Now I see 7 pages of unread topics  ;D

I will test it this weekend, thanks again Emanuele
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 24, 2016, 06:37:40 am
ROFL!
Take your time on catching up! :P
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on June 26, 2016, 05:03:17 pm
It does the job, no bbcode added to links and whitelisted domains are without nofollow, thank you Emanuele  ;)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 26, 2016, 05:16:58 pm
YAY! :D

Spoiler (click to show/hide)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on June 28, 2016, 05:41:28 pm
there is a little problem with the addon: if I insert a link using the button into sceditor, the bbcode became:

Code: [Select]
[url url=http://www.google.it nofollow=dofollow]prova link[/url]

and if I click on the link it opens a new tab with the same topic: http://www.domain.com/index.php?topic=xx.new

the nofollow bbcode is really necessary? I think not, because all old links non whitelisted are getting correctly the nofollow atribute. Correct me if I am wrong
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 29, 2016, 04:16:52 am
The reason there is the nofollow attribute is to actually white-list the links: by default anything is nofollow, then I need a way to tell the parser "ok, this is not a nofollow", and there is it the param.

Just to be sure I understand:
1) start a new message,
2) turn on WYSIWYG
3) insert a (named) link
4) post
expected: the link points to the address
observed: the link points to the original topic

Did I got it right?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on July 03, 2016, 08:13:18 am
Sorry for the delay, I unistalled the addon from my forum, too many broken links so I installed it in a test board:
sharkracingclub.it/sharkelk104/index.php?topic=2655
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on July 06, 2016, 05:59:05 am
Stupid me...
I'll update the package, in the meantime, in NoFollow.integrate.php, just find:
Code: [Select]
						{
$param = \'http://\' . $param;
}
and add just after:
Code: [Select]
						return $param;

sorry for the n00b error... :-[
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on July 06, 2016, 02:49:37 pm
that solved the problem with links pointing to current topic, thank you. I still test it and try to find other bugs ;)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on July 06, 2016, 05:27:43 pm
No, you don't have to find bugs. :P
Title: Re: [ADDON] Nofollow attribute for external links
Post by: elk_is_cool on September 13, 2016, 05:22:48 pm
Thanks guys for this plugin, exactly what I was looking for.  

I was going to give a poster in my forum the gift of "dofollow" to her blog, until I see she was advertising products on Amazon using keywords.   Now, if she wants to give me a percentage.....that's a different story!

Keep finding those bugs for Emanuele folks....
maybe we can start a collection to pay for more coffee for him,  while he's up late correcting them!   ;D
Title: Re: [ADDON] Nofollow attribute for external links
Post by: ahrasis on September 14, 2016, 01:50:29 pm
Interesting... I didn't follow this before, so I'm parking in and will test this later.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: elk_is_cool on September 22, 2016, 12:03:39 pm
It works Ahrasis.  Highlight the keywords the poster is linking to, then right click to bring up  "inspect element" using FF.  Then it shows the link is a nofollow!  Why should I be giving away free link juice?  No more!
Title: Re: [ADDON] Nofollow attribute for external links
Post by: ahrasis on September 22, 2016, 07:51:39 pm
Is it a permission based? I haven't look into the code yet.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on September 23, 2016, 01:16:10 pm
I feel email don't really have any reason to be nofollow.
The only option is to mask them somehow, but add the nofollow attribute is not of great help.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 02, 2017, 09:14:09 am
I am getting some errors in elkarte log:
Undefined index: host
sources/subs/NoFollow.integrate.php Line: 174

line 174 is:
Code: [Select]
			if (substr($parsed['host'], -strlen($valid_domain)) === $valid_domain)

The errors are related to some topics and in search results. Any suggestion to solve this?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 02, 2017, 04:06:09 pm
Do you have the URLs of the searches?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 02, 2017, 04:55:09 pm
Code: [Select]
https://www.sharkracingclub.it/index.php?action=search;sa=results;params=eJwtzksOwjAMBNC7sGEzQs2_nKZKE4sWQoPSFISUw-Oibkbjt7Dt49svgWI7t66d2lj2ZhyMhoHSUAoSQkFYSAGhYQUsp4MTkBZOwUJraAnTw0FZCAHN2UFdoVh69JpXr1P-DCE_X4kq8ZGdtvFOoQ55Sd9DcqncCiX6_3XQEOfCHGkNu5AvYeJ5nXx5FB_m5RbSNl7m-gO70UGj;start=60

and a topic where I see the error sharkracingclub.it/index.php?topic=2944.15
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 02, 2017, 06:14:57 pm
And no other errors?
That's strange... :-\

Memo to self: the code should ignore the www.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 02, 2017, 08:20:14 pm
I cleared the erros, I just did a search for tag (img] and I get another error:
type of error: Undefined
Undefined index: host
https://www.sharkracingclub.it/index.php?action=search;sa=results
 File: /sources/subs/NoFollow.integrate.php
Line: 177


Tomorrow I will look better in the other forum, there I got more errors.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 03, 2017, 05:33:41 am
What version of php?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 03, 2017, 05:51:55 am
temporary I switched to 5.4, but usually I use 5.6
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 03, 2017, 10:35:15 am
Exactly what php 5.4 version is it?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 03, 2017, 10:45:40 am
5.4.45  O:-)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 03, 2017, 05:03:49 pm
headscratch
And with 5.6 it was working?

/me is temped to blame php and declare 5.6 the minimum version. xD

Seriously: I have to look into it.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 03, 2017, 05:24:13 pm
with php5.4 I only got 2 errors in the last 8 hours
Guest
Type of error: Undefined
 Undefined index: host
https://www.sharkracingclub.it/index.php?topic=2944.15
File: /srv/users/serverpilot/apps/sharkracingclub/public/sources/subs/NoFollow.integrate.php
Line: 177


I switch now to php5.6 to see if I get other errors
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 20, 2017, 08:34:52 am
I found some errors in Elkarte log, all of them are related to this topic http://www.skodaclub.it/index.php?topic=4799.0
I am using php 5.6

8: Undefined index: host
File: /sources/subs/NoFollow.integrate.php
Line: 177

The strange thing is there is no link on that page, only a youtube video. Could be this?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on March 22, 2017, 03:45:30 pm
Another stupid error. :-\

In NoFollow.integrate.php, change:
Code: [Select]
$message = preg_replace_callback('~<a href="(.*?)" class="bbc_link" rel="nofollow"(?: target=".*?")?>~', array(self::$instance, 'replace_callback'), $message);
to:
Code: [Select]
$message = preg_replace_callback('~<a href="([^>]*?)" class="bbc_link" rel="nofollow"(?: target="_?\w+")?>~', array(self::$instance, 'replace_callback'), $message);
that should do.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on March 22, 2017, 08:13:36 pm
thank you, no more errors from that topic  ;)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on September 19, 2017, 06:45:03 pm
I just installed this on 1.1 RC2, it installs without errors, but it's not working. If I publish a link like
Code: [Select]
[url=https://www.google.it]google.it[/url]
becames:
Code: [Select]
[url url=https://www.google.it nofollow=dofollow]google.it[/url]
but there is no link visible, only text.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on December 17, 2017, 05:07:31 pm
@emanuele‍ do you have any plans to update this addon for elkarte 1.1? Thank you
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on April 29, 2020, 02:17:44 pm
is there any improvement?

I installed in version 1.1.6 does not add nofolow
Title: Re: [ADDON] Nofollow attribute for external links
Post by: radu81 on April 29, 2020, 06:27:12 pm
the add-on is not compatible with elkarte 1.1
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 15, 2020, 02:24:33 pm
Hi,

@emanuele

can you give information about working with code editing?

a detailed revision is required
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 20, 2020, 02:21:35 am
hmm... BBC parser.
From @radu81 comment I'd say the problem is in the parsing, though right not I'm not entirely sure why it should not work (apart from the fact it still uses create_function and messes with http/https).
This evening I'll try to have a look.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 20, 2020, 03:58:32 pm
I tried, honestly I didn't test it at all. From this to time this happens to work out well, not always. xD
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 21, 2020, 02:55:20 am
Thanks @emanuele   works, there is a problem  but also affects main site links


Code: [Select]
<a href="https://MAIN-SITE.com" class="bbc_link" rel="noopener noreferrer nofollow" target="_blank">"https://MAIN-SITE.com</a>


<a href="https://EXTERNAL-SITE.com" class="bbc_link" rel="noopener noreferrer nofollow" target="_blank">https://EXTERNAL-SITE.com</a>


                  
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 21, 2020, 07:28:51 am
I guess I don't like to do assumptions, that's likely why there is a "white list" setting in the admin panel.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 21, 2020, 11:30:43 am
Thanks.  I found the settings but after saving it gave error

click check box (internal site)  and add one site link white link area  (https://www.site.com)  save setting

error setting page appears;

Code: [Select]
implode(): Invalid arguments passed

and the setting page always gives the same error

I can access the settings page when I uninstall the plugin

it again error page appears when installing the plugin again
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 23, 2020, 05:39:54 am
There should be also something else along with the error, like the file and the row number.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 23, 2020, 06:29:17 am
Hi,

 File: /sources/subs/NoFollow.integrate.php
 Line: 142

(Link-6516)

a different error appears click "back" button;

(Link-6518)



Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 23, 2020, 02:11:00 pm
Please try changing:
Code: [Select]
$modSettings['nofollow_whitelist'] = implode("\n", json_decode($modSettings['nofollow_whitelist']));
to:
Code: [Select]
$modSettings['nofollow_whitelist'] = implode("\n", json_decode($modSettings['nofollow_whitelist'], true));
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 23, 2020, 02:37:37 pm
I've tried. the same error appears

 File: /sources/subs/NoFollow.integrate.php
 Line: 142
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on May 30, 2020, 10:21:47 am
Oook, now I got it.
Try the one attached here.
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on May 31, 2020, 06:50:06 am
Thanks it works .
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on June 01, 2020, 05:31:13 am
Good!
Php 7+ annoying errors... :-\
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on July 02, 2020, 02:40:33 am
Hi,

@emanuele     I noticed a new problem,

If add link editor button is used,  is not clickable url. Appears in text format

[url url=https://site.com/sample-post/ nofollow=dofollow]Sample Post[/url]

Edit: + image upload sites BBC image code. Not clickable url. Appears in text format

(Link-6531)
Title: Re: [ADDON] Nofollow attribute for external links
Post by: emanuele on July 07, 2020, 04:49:31 pm
hmm... that has likely to do with some relatively new feature of the editor.
And that means I have to investigate it further, though to debug javascript I need time, so... it will take a while.

ETA: I suppose you mean the WYSIWG editor, right?
Title: Re: [ADDON] Nofollow attribute for external links
Post by: gevv on July 08, 2020, 04:54:10 am
yes wysiwg editor (or bbcode  problem)

(Link-6533)

(Link-6535)

(Link-6537)