Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Finaly, texy! for snews  (Read 7744 times)

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #15 on: March 23, 2008, 06:40:42 pm »

Do you know if there is an english language version of the source site?
Up to date there does not exist english version, but they are working on it (asi could read in guest book). At least, they are working on English verion on Texyla.
But if there is some exact place which you want to translate, maybe I can help you.

Back to the topic: With some edits I think I can make FSHL (the fastest php syntax highlihter) working with this because it is already working with Texy! on WordPress etc.
Logged

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #16 on: March 24, 2008, 06:49:08 pm »

Hi,
I want to make comments going trought the texy (like arctiles), but I can not find right place (place whre are comment's texts echoed). can someone help me?
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Finaly, texy! for snews
« Reply #17 on: March 24, 2008, 07:26:39 pm »

You not answered why...

Comments are cleaned of every html code. But I saw a little bbcode parser in Article Script 1.1 of Johan Hornquist. It allows text formating, links and images (hotlink). If you want it....

Anyway, here it is:
Code: [Select]
<?php
//
// BBCode function, this changes BBCode to HTML
//

function BBCode($str) {
   
$str nl2br(stripslashes($str));

   
$change = array(
                
'/\[b\](.*?)\[\/b\]/is',                                
                
'/\[i\](.*?)\[\/i\]/is',                                
                
'/\[u\](.*?)\[\/u\]/is',                                
                
'/\[url\=(.*?)\](.*?)\[\/url\]/is',                         
                
'/\[url\](.*?)\[\/url\]/is',                             
                
'/\[align\=(left|center|right)\](.*?)\[\/align\]/is',    
                
'/\[img\](.*?)\[\/img\]/is',                                                      
                
'/\[font\=(.*?)\](.*?)\[\/font\]/is',                    
                
'/\[size\=(.*?)\](.*?)\[\/size\]/is',                    
                
'/\[color\=(.*?)\](.*?)\[\/color\]/is',        
                );

   
$with = array(
                
'<strong>$1</strong>',
                
'<em>$1</em>',
                
'<u>$1</u>',
                
'<a href="$1">$2</a>',
                
'<a href="$1">$1</a>',
                
'<div style="text-align: $1;">$2</div>',
                
'<img src="$1" />',
                
'<span style="font-family: $1;">$2</span>',
                
'<span style="font-size: $1;">$2</span>',
                
'<span style="color: $1;">$2</span>',
                );

   
$str preg_replace($change$with$str);

   
$str bb_smilies($str);

   
//$str = cleanXSS($str);

   
return $str;


?>


As you see, it use also smilies function of bakercad and if you want to use it,
Locate in function comment this line:
case ($tag == 'comment'): echo bb_smilies($r['comment']); break;

And replace with this:
case ($tag == 'comment'): echo BBCode($r['comment']); break;


Maybe this is a clue for your Texy! adaptation.

UPDATE:

Oops! Maybe you don`t have smilies module yet...

Then look for this line in function comment:
case ($tag == 'comment'): echo $r['comment']; break;
« Last Edit: March 24, 2008, 10:06:02 pm by funlw65 »
Logged

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #18 on: March 24, 2008, 08:23:16 pm »

Quote
Palmik, this editor is great for admin but why you want to let people to insert in comments links and images?
I do not want to let people insert images or something, because I can easily disallow it to one instance of Texy! to use some tags...
Why I want Texy! for comments? Because People can easily formate their comments in to the readeable form.
Texy! have also safemode, so maybe it would be easier to remove html tags removing.

My textarea for comments now look like on the screen.
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Finaly, texy! for snews
« Reply #19 on: March 24, 2008, 09:33:48 pm »

I like it!

One big obstacle can be the speed because is an @interpreter/translator for every page, article and comment.
« Last Edit: March 24, 2008, 09:48:11 pm by funlw65 »
Logged

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #20 on: March 25, 2008, 03:45:44 pm »

Yes maybe speed would be obstacle but Texy! can easily work with cachet texts, but how to implement it to sNews I do not know...
Anyway I tried this
Code: [Select]
            $texy_comm = new Texy();
            $r['comment'] = $texy_comm->process(($r['comment']));
And it have no succes. Dunno why.
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Finaly, texy! for snews
« Reply #21 on: March 25, 2008, 04:12:04 pm »

Quote from: Palmik
Yes maybe speed would be obstacle but Texy! can easily work with cachet texts, but how to implement it to sNews I do not know...
Anyway I tried this
Code: [Select]
            $texy_comm = new Texy();
            $r['comment'] = $texy_comm->process(($r['comment']));

And it have no succes. Dunno why.


Try this:
Quote
case ($tag == 'comment'):
      $texy_comm = new Texy();
      echo  $texy_comm->process($r['comment']);
break;

Or this:
Quote
case ($tag == 'comment'):
      $texy_comm = new Texy();
      $texy_comm->process($r['comment']);
      echo $texy_comm;
break;

Is a replacement for this:
case ($tag == 'comment'): echo $r['comment']; break;
---------------------------------------------------

Edit:


Maybe better put this part of code $texy_comm = new Texy(); at begining of function comment as variable initialization.

Sorry, put this part of code $texy_comm = new Texy(); before this line:
while ($r = mysql_fetch_array($result)) {
Is located few rows up.
« Last Edit: March 25, 2008, 04:30:24 pm by funlw65 »
Logged

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #22 on: March 25, 2008, 07:21:05 pm »

Your codes was not correct like mine before, but U give me a general clue...
1. Replace
Code: [Select]
case ($tag == 'comment'): echo $r['comment']; break;
with
Code: [Select]
            case ($tag == 'comment'):
               $r['comment'] = $texy_comm->process($r['comment']);
               echo $r['comment'];
            break;
2. Replace
Code: [Select]
while ($r = mysql_fetch_array($result)) {
$date = date($date_format, strtotime($r['time']));
With
Code: [Select]
[code]
while ($r = mysql_fetch_array($result)) {
$texy_comm = new Texy();
$date = date($date_format, strtotime($r['time']));

... But there is one issue and that is that comments were inside <p></p> but they are not now... so it looks like here[/code]
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Finaly, texy! for snews
« Reply #23 on: March 25, 2008, 11:35:53 pm »



As you see, with next code is working but you have one problem to solve: comments editor insert this
Code: [Select]
<br /> at every end of line. Maybe because I inserted text example by copy&paste from Texi! site. I edited the second time by hand and it was ok (no second screenshot, sorry). Now, the code:

In function comment, before this line:
while ($r = mysql_fetch_array($result)) {

you must put this:
Code: [Select]
//texicommentMOD(
    $texy = new Texy();
//)

and replace this line:
case ($tag == 'comment'): echo $r['comment']; break;

with this code
Code: [Select]
//texicommentMOD(
//case ($tag == 'comment'): echo $r['comment']; break;
case ($tag == 'comment'): 
$texytext = $texy->process($r['comment']);
echo $texytext;
break;
//)

----------------------------
I tested this code on sNews 1.6, not multiuser version.... but I think is ok... The code is from you, as is in your first post. Sorry for first mistake, I was in rush. Pages are loaded very slow on localhost and with comments, even slower. Some time, strange display errors can appear but maybe because is in beta stage. Back slashes are striped.
After the while cycle, you must 'destroy' texy object to preserve memory (I programmed in object pascal, don't know if here is the case). texy->free(); ?  ???

I think the best solution for formatting comments is still a BBcode parser. You can see an example of a comment parsed with BBCode with little modification here.
Or you can use Wordpress for your Texi! .
« Last Edit: March 26, 2008, 08:03:16 pm by funlw65 »
Logged

Palmik

  • Jr. Member
  • **
  • Karma: 2
  • Posts: 58
    • Palmik's Page
Re: Finaly, texy! for snews
« Reply #24 on: May 03, 2008, 09:53:18 pm »

Nothing agains Worpress, but I think that I can better seo optimize sNews that WP. I get PR 3 after 1 month (first PR recalculation).
Anyway... I am back now.  And ty for your code, I will look at it tomorow (i hope)
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: Finaly, texy! for snews
« Reply #25 on: May 03, 2008, 10:14:12 pm »

Palmik,
If you don`t want to have problems with break page when you use texy for articles, make this modification first:
http://snewscms.com/forum/index.php?topic=5736.msg50004#msg50004

But instead of this line:
echo bb_smilies(file_include(str_replace('[break]', '', $text), $shorten));

Use this:
$texytext = $texy->process(file_include(str_replace('[break]', '', $text), $shorten));
echo $texytext;


Of course, you must first new instance $texy:
    $texy = new Texy();

I learned on other languages that is good to instantiate only once, that is the reason I put it before while cycle... you can try also inside...
« Last Edit: May 03, 2008, 10:19:56 pm by funlw65 »
Logged
Pages: 1 [2]