OCDProgrammer.com

It's Microsoft's World, and I'm just living in it
View Clarence Klopfstein's profile on LinkedIn

Clarence Klopfstein's Facebook profile

This site is under construction...

Categories

New Comments

Referring Sites


Disclaimer

  • This is MY blog. The views represented here are not in relation to anybody else. Please read my full disclaimer for a more complete disclaimer.

Quicker Links - DNBE - Extension

November 30, 2007 22:21 by ckincincy

I have developed a new extension for the DNBE platform.  This feature will replace certain key words with a link to a site you specify.  I have named it "Quicker Links", and using it is rather easy.

After following the README.txt file in the zip file you will see a new tab in your administrative section of your site.

In that page you can specify what words to replace with what links.  For example, I have specified the short cut dnbe to be replaced with a link to Dot Net Blog Engine's website.

This works pretty easily, you enter the text on the left and it will be made into a link.

So download it for yourself! 

QuickerLinks.zip (6.01 kb) - Version 1.0 - December 1, 2007

Now I have tried to account for many different ways for this text to appear in HTML, but I'm sure it could use some improvement.  So if you have a code change let me know!  Here what the code should be able to replace in version one.  Lets assume that you have ckurl defined in your entry to be replaced with a link. 

  • If you just have it normally in a sentence, like above it will become a link. 
  • I also allow for certain punctuation to follow the word (!.,?:).
  • I check for a leading or trailing HTML bracket <, or >.  This is mainly if the word appears after a paragraph or line break.
  • I allow it if the word is followed by a space.  So lets say I have ckurl at the beginning of a sentence it will be replaced with a link.
    • NOTE: This introduced the only known bug.  If your word is in the end of a word it will break that word and give you a link.  For example if I have this wordckurl, the ckurl part of that will become a link.  Would love some better regular expressions for this, so I'm all ears.
  • One last note, I ignore case here.  So if you type cKuRl, it will make that word... just as it is a link.

Well I hope you enjoy! 



Comments

December 1. 2007 01:22

Sweet!  Just what I had in mind.  I have already loaded it and it works fantastic!

Thank you!

Chris |

December 1. 2007 18:35

Glad I could help.  I had planned on developing this since I did my last one, because there are certain phrases I'd like to always be a link.  Now I don't have to type the extra characters that my Quick Links extension requires.

ckincincy |

December 5. 2007 17:48

Had difficulty setting it up but I then added the following to my web.config in admin/pages folder:
<location path="quickerlinks.aspx">
    <system.web>
      <authorization>
        <allow roles="administrators"/>
        <deny users="*" />
      </authorization>
    </system.web>
  </location>
Hope this helps. Let me know if this is supposed to affect the implementation. Thanks a million your efforts make my life so much easier.

Nigel |

December 5. 2007 18:20

Hmmm that is an interesting issue.

What does your admin/web.config file look like?

ckincincy |

December 5. 2007 19:15

same as the above, but for all the .aspx pages in admin/pages/. I am no expert and am wondering if it was not implementing due to some other error I made. It really works well and I am trying to figure out how I can get your extesnion to work on the pages section as well as the blog section.

Nigel |

December 5. 2007 19:25

Well thats the reason for your issues, my admin/web.config file has this in it (which gives full rights to access the pages to all logged in users):
<?xml version="1.0"?>
<configuration>
  <system.web>
    <pages enableSessionState="true" />
    <authorization>
      <deny users="?" />
    </authorization>
  </system.web>
</configuration>

For it to save on pages you'd probably need this line in the QuickerLinks.cs file:
Page.Saving += new EventHandler<BlogEngine.Core.SavedEventArgs>(Post_Saving);

Adds the event to the PAGE saving event.

ckincincy |

December 6. 2007 07:20

Thanks,again a really useful extension. Now I can see exactly what happened- will give it a go on the pages soon.

Nigel |

December 31. 2007 02:55

Pingback from dotnetblogengine.net

Extensions

dotnetblogengine.net |

January 13. 2008 19:20

For the regex in the bug you mentioned, sounds like you could do it with either a word boundary match (I think \b) or a look-behind assertion (I think (?<=...) or (?<!...)). Feel free to email me specific details if you'd like additional help.

Josh |

Comments are closed