Палсеич— (lusever) wrote in changelog,
Палсеич—
lusever
changelog

[livejournal] r16120: LJSV-866: linking to both a user and a c...

Committer: pkornilov
LJSV-866: linking to both a user and a community in the RTE erases the content between those lj user tags.
U   trunk/htdocs/js/rte.js
U   trunk/htdocs/js/test/rte.js
Modified: trunk/htdocs/js/rte.js
===================================================================
--- trunk/htdocs/js/rte.js	2010-01-25 04:38:20 UTC (rev 16119)
+++ trunk/htdocs/js/rte.js	2010-01-25 05:52:36 UTC (rev 16120)
@@ -274,11 +274,11 @@
 
 function convert_user_to_ljtags(html) {
 	html = html
-		.replace(/<span.*?class="ljuser.*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/(?:[^<]|<[^b])*<b>\1<\/b><\/a><\/span>/g, '<lj comm="$1"/>')
-		.replace(/<span.*?class="ljuser.*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/(?:[^<]|<[^b])*<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj comm="$1" title="$2"/>')
-		.replace(/<span.*?class="ljuser.*?><a href="http:\/\/users\.[-.\w]+\/([\w]+)\/(?:[^<]|<[^b])*<b>\1<\/b><\/a><\/span>/g, '<lj user="$1"/>') // username with special symbol
-		.replace(/<span.*?class="ljuser.*?><a href="http:\/\/users\.[-.\w]+\/([\w]+)\/(?:[^<]|<[^b])*<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj user="$1" title="$2"/>')
-		.replace(/<span.*?class="ljuser.*?><a href="http:\/\/([-\w]+)\.(?:[^<]|<[^b])*<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj user="$1" title="$2"/>')
+		.replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/.*?<b>\1<\/b><\/a><\/span>/g, '<lj comm="$1"/>')
+		.replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/(?:community|syndicated)\.[-.\w]+\/([\w]+)\/.*?<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj comm="$1" title="$2"/>')
+		.replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/users\.[-.\w]+\/([\w]+)\/.*?<b>\1<\/b><\/a><\/span>/g, '<lj user="$1"/>') // username with special symbol
+		.replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/users\.[-.\w]+\/([\w]+)\/.*?<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj user="$1" title="$2"/>')
+		.replace(/<span[^>]*?class="ljuser[^>]*?><a href="http:\/\/([-\w]+)\..*?<b>([^<]+)?<\/b><\/a><\/span>/g, '<lj user="$1" title="$2"/>')
 		.replace(/<\/lj>/g, '');
 	
 	//change user-name to user_name

Modified: trunk/htdocs/js/test/rte.js
===================================================================
--- trunk/htdocs/js/test/rte.js	2010-01-25 04:38:20 UTC (rev 16119)
+++ trunk/htdocs/js/test/rte.js	2010-01-25 05:52:36 UTC (rev 16120)
@@ -3,9 +3,9 @@
 
 // "lj @user", "lj @user @title", test machine
 fireunit.compare(convert_user_to_ljtags('\
-    <div class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://test.lj-10.bulyon.local/"><b>test</b></a></div><div class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://test.lj-10.bulyon.local/"><b>elk\s\'wlk;w</b></a></div>\
+    <span class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://test.lj-10.bulyon.local/"><b>test</b></a></span><span class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://test.lj-10.bulyon.local/"><b>elk\s\'wlk;w</b></a></span>\
     <br />\
-    <div class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://www.lj-10.bulyon.local/img/userinfo.gif" /></a><a href="http://test.lj-10.bulyon.local/"><b>test</b></a></div>')
+    <span class="ljuser"><a href="http://test.lj-10.bulyon.local/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://www.lj-10.bulyon.local/img/userinfo.gif" /></a><a href="http://test.lj-10.bulyon.local/"><b>test</b></a></span>')
     ,
     '\
     <lj user="test"/><lj user="test" title="elk\s\'wlk;w"/>\
@@ -15,9 +15,9 @@
 
 // username with "_"
 fireunit.compare(convert_user_to_ljtags('\
-    <div class="ljuser"><a href="http://ki-zu.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://ki-zu.livejournal.com/"><b>ki_zu</b></a></div>\
+    <span class="ljuser"><a href="http://ki-zu.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://ki-zu.livejournal.com/"><b>ki_zu</b></a></span>\
     <br />\
-    <div class="ljuser"><a href="http://ki-zu.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://ki-zu.livejournal.com/"><b>ki-zu</b></a></div>')
+    <span class="ljuser"><a href="http://ki-zu.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://ki-zu.livejournal.com/"><b>ki-zu</b></a></span>')
     ,
     '\
     <lj user="ki_zu"/>\
@@ -27,9 +27,9 @@
 
 // username start with "_"
 fireunit.compare(convert_user_to_ljtags('\
-    <div class="ljuser"><a href="http://users.livejournal.com/__h4__/profile"><img width="17" height="17" src="http://l-stat.livejournal.com/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://users.livejournal.com/__h4__/"><b>__h4__</b></a></div>\
+    <span class="ljuser"><a href="http://users.livejournal.com/__h4__/profile"><img width="17" height="17" src="http://l-stat.livejournal.com/img/userinfo.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://users.livejournal.com/__h4__/"><b>__h4__</b></a></span>\
     <br />\
-    <div class="ljuser"><a href="http://akella_art.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://akella_art.livejournal.com/"><b>akella</b></a></div>')
+    <span class="ljuser"><a href="http://akella_art.livejournal.com/profile"><img width="17" height="17" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/userinfo.gif" /></a><a href="http://akella_art.livejournal.com/"><b>akella</b></a></span>')
     ,
     '\
     <lj user="__h4__"/>\
@@ -39,11 +39,11 @@
 
 // community
 fireunit.compare(convert_user_to_ljtags('\
-    <div class="ljuser"><a href="http://community.lj-10.bulyon.local/lj_core/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/community.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://community.lj-10.bulyon.local/lj_core/"><b>lj_core</b></a></div>\
+    <span class="ljuser"><a href="http://community.lj-10.bulyon.local/lj_core/profile"><img width="17" height="17" src="http://www.lj-10.bulyon.local/img/community.gif" alt="[info]" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" /></a><a href="http://community.lj-10.bulyon.local/lj_core/"><b>lj_core</b></a></span>\
     <br />\
     lj_core\
     <br />\
-    <div class="ljuser"><a href="http://community.livejournal.com/changelog/profile"><img width="16" height="16" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/community.gif"/></a><a href="http://community.livejournal.com/changelog/"><b>changelog "2 test</b></a></div>')
+    <span class="ljuser"><a href="http://community.livejournal.com/changelog/profile"><img width="16" height="16" style="border: 0pt none ; vertical-align: bottom; padding-right: 1px;" alt="[info]" src="http://l-stat.livejournal.com/img/community.gif"/></a><a href="http://community.livejournal.com/changelog/"><b>changelog "2 test</b></a></span>')
     ,
     '\
     <lj comm="lj_core"/>\
@@ -53,6 +53,14 @@
     <lj comm="changelog" title="changelog \"2 test"/>',
     'ljuser"');
 
+// username & community
+fireunit.compare(convert_user_to_ljtags('\
+    <span class="ljuser ljuser-name_test" lj:user="test" style="white-space: nowrap;"><a href="http://test.lj-10.bulyon.local/profile"><img src="http://www.lj-10.bulyon.local/img/userinfo.gif" alt="[info]" style="vertical-align: bottom; border: 0pt none; padding-right: 1px;" height="17" width="17"></a><a href="http://test.lj-10.bulyon.local/"><b>test</b></a></span> ljuser and community <span class="ljuser ljuser-name_sup_comm" lj:user="sup_comm" style="white-space: nowrap;"><a href="http://community.lj-10.bulyon.local/sup_comm/profile"><img src="http://www.lj-10.bulyon.local/img/community.gif" alt="[info]" style="vertical-align: bottom; border: 0pt none; padding-right: 1px;" height="16" width="16"></a><a href="http://community.lj-10.bulyon.local/sup_comm/"><b>sup_comm</b></a></span>&nbsp;')
+    ,
+    '\
+    <lj user="test"/> ljuser and community <lj comm="sup_comm"/>&nbsp;',
+    'ljuser and community');
 
 
+
 fireunit.testDone();

Tags: js, livejournal, lusever
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments