sNews Forum

sNews 1.6 (previous version) => Mods/addons => Topic started by: Palmik on March 22, 2008, 11:39:54 am

Title: Finaly, texy! for snews
Post by: Palmik on March 22, 2008, 11:39:54 am
Long time ago I had a dream - texy in snews, and now it looks that my dream beceme a real. (If only I had know that it will be so easy)
Skip this part and go in to the instaltion

1. Dowlonad Texy! here (http://download.texy.info/?texy-2.0-beta2.zip) (it is Texy2 beta)
2. Open your index.php and change following
Code: [Select]
<?php session_start(); include('snewsMU.php')?>with
Code: [Select]
<?php session_start(); include('snewsMU.php'); include_once('texy/texy.php');?>3. Open your sNews(MU).php and find
Code: [Select]
file_include (str_replace ('[break]','', $text), $shorten);replace it with
Code: [Select]
    $texy = new Texy();
    $texytext = $texy->process($text);
    file_include (str_replace ('[break]','', $texytext), $shorten);
4. Look at the Texy! syntax here, it is very nice and sexy :D http://texy.info/en/syntax
5. Was not it easy? :) Only thing to finish it is to find place where are comments parsed and add it here too. :)


Title: Re: Finaly, texy! for snews
Post by: Keyrocks on March 22, 2008, 03:08:47 pm
Hmmm... you've got me interested... will have to try this out right away (almost).  :)
Title: Re: Finaly, texy! for snews
Post by: Keyrocks on March 22, 2008, 04:44:45 pm
@ Palmik... what's the 'secret' to making it work? I can't see anything - sNews textarea is still the default one. Maybe I am missing something... there are no install instructions... what do I put in the sNews root to make it work?
I am testing this in a default sNews 1.6 project (no MU). So far... I...
- copied the texy folder into the sNews root,
- did your step 2, and step 3
Title: Re: Finaly, texy! for snews
Post by: jared351 on March 22, 2008, 06:53:39 pm
You probably did everything right Keys, so now you can use the Texy syntax. You can read more about the syntax http://texy.info/en/syntax (http://texy.info/en/syntax) <-- there. For example, when you type in something like this in the textarea:

Code: [Select]
Lorem ipsum dolor sit amet,
still the same paragraph.

Second paragraph

It should go to something like this for the output:

Code: [Select]
<p>Lorem ipsum dolor sit amet, still the same paragraph.</p>

<p>Second paragraph</p>

Correct me if I'm wrong please.
Title: Re: Finaly, texy! for snews
Post by: Joost on March 22, 2008, 07:25:02 pm
How does it cope with [break] ?
Title: Re: Finaly, texy! for snews
Post by: funlw65 on March 22, 2008, 07:33:29 pm
This is great Palmik. It needs a little effort to learn the syntax but is worthy. I think I will make a package with this only for me :D

I looked into syntax and not saw any conflict. But I think the problem is when is surrounded by p tags.... here come in place the Read more mod (read more inside article) I think...
Title: Re: Finaly, texy! for snews
Post by: Palmik on March 22, 2008, 07:38:12 pm
How does it cope with [break] ?
Perfectly I think. I did not find any problem, and one big plus is that you must not "convert" old articles.

@ Keyrocks
By the link I had provided to you you will download directory with name "texy-2.0-beta2"... I uploaded directory with name "texy" to my root.

@ ared351
This is the last thing, you can handle links, paragraphs, headings, tables and many more...
Title: Re: Finaly, texy! for snews
Post by: Keyrocks on March 22, 2008, 09:57:10 pm
You probably did everything right Keys, so now you can use the Texy syntax. You can read more about the syntax http://texy.info/en/syntax (http://texy.info/en/syntax) <-- there.
Correct me if I'm wrong please.

Right you are. I was expecting to see a "new" textarea panel. So it's invisible... 3 lines separated by a line-space and using no tag-wrappers... displays as 3 separate paragraphs. Hmmm... very convenient thus far. Must now figure out how the syntax sensing works.
Question... does this mean we could actually do away with the default tag generator buttons altogether? Perhaps we'll learn the answer as we go.  :)
Title: Re: Finaly, texy! for snews
Post by: Palmik on March 22, 2008, 10:03:26 pm
Yes, default tags are with this mod gimcrack. Benefits from this mod are, that the text taged with texy! syntax is clearly readeable and it does not require any html skills, so it would be nice to implement it for the comments too, but find place where comments are being parsed would be (at least for me) the hardest thing.
Title: Re: Finaly, texy! for snews
Post by: funlw65 on March 22, 2008, 10:28:27 pm
Palmik, this editor is great for admin but why you want to let people to insert in comments links and images?
Title: Re: Finaly, texy! for snews
Post by: Keyrocks on March 22, 2008, 10:44:18 pm
Palmik... Thanks for sharing the Texy addon with us. I ran through all of the syntax examples from the Texy site.
My Impression... It's pretty decent for anyone that doesn't mind learning the syntax bits that need to be inserted. I noticed that not all syntax works with others... such as inserting a block of code in between 2 horizontal lines... and using the blockquote syntax between 2 horizontal lines... as examples that I could not get to work. I tried several variations of spacing... no luck.

While it's true that the user doesn't need to use any HTML... the user still needs to have a reference for the Texy syntax insertions... another language form that isn't so convenient for the non-techie user.

The user doesn't need to understand HTML to use the tag generator buttons that come in the default sNews editor... just needs to know how to highlight the text and click the button. Same with the custom icon-based tag generator buttons that come with the Admin Panels in the MESU and MEMU packages... additional functionality using the existing sNews tag generator function.

If I were going to add another editor to an sNews project... I would rather use a WYSIWYG addon... like TinyMCE for example. My clients would find it more convenient to use than Texy. That's just my own impression... giving it a try was interesting tho.   :)
Title: Re: Finaly, texy! for snews
Post by: Nicu Alecu on March 23, 2008, 12:06:18 am
Agreed, Keyrocks! I ran into texy about 6 month ago (about the same time I ran into sNews) and really liked it ... but that's just me! none of my non-html-ed clients ever thought of "learning" some "editing syntax", when presented with both options: texy & tinymce. I even presented a third option, fckeditor, which is more powerfull and complete that tinymce, but no luck on fck either. Almost everybody went the tinymce way, due to it's simplicity and easy learning curve.
Title: Re: Finaly, texy! for snews
Post by: Palmik on March 23, 2008, 12:37:02 pm
Yeah, maybe, but there are also mods for texy!, like Texyla (http://texyla.jaknato.com/) (texy! editor, where you can see what you get... pali was talking about it some time ago).
For me is Texy! good for one reason and it is readability of long texts.

Code: [Select]
Header
======
- list
- list
- **bold list**
- "text of the link":http://url.something
- x^2 + y^3

vs

Code: [Select]
<h2>header</h2>
<ul>
<li>list</li>
<li><strong>bold list</strong></li>
<li><a href="http://url.something">texyt of the link</a></li>
<li>x<sup>2</sup> + y<sup>3</sup></li>
</ul>

Maybe differece is not clearly visible, but if you are writing quite long texts it is visible
Title: Re: Finaly, Texy and Texyla
Post by: Palmik on March 23, 2008, 05:27:07 pm
Hi, so I tryed to apply Texyla (http://texyla.jaknato.com/) (texy! editor)on sNews and it works... :)
So, here is an tutorial :)

1. Download Texyla! here (http://texyla.jaknato.com/stahnout.php) and upload it to your root (upload only directory texyla and futher)
2. to your index.php add line
Code: [Select]
<script type="text/javascript" src="texyla/texyla.js"></script>3. In your sNews(MU).php find
Code: [Select]
echo html_input('textarea', 'text', 'txt', $frm_text, l('text'), '', '', '', '', '', '2', '100', '', '', ''); and after this add
Code: [Select]
    echo '<script language="JavaScript">';
    echo 'new Texyla(Texyla.configurator.admin(\'txt\'));';
    echo '</script>';

I had been talking about Texyla in sNews with pali, but his version was not working correctly so I made my own one.

But, there is one bug (I thing its buggy because of collapsing sNews with texy) - you can put [break] after lists, italics or bold, because rest of page would be list, bold or italic. May be it is because of this part of code
Code: [Select]
    $texy = new Texy();
    $texytext = $texy->process($text);
    file_include (str_replace ('[break]','', $texytext), $shorten);
Maybe there is better place to past text through texy!

Edit: Of course you can delete, or comment out this lines
Code: [Select]
echo '<p>';
echo html_input('button', 'strong', '', 'B', '', 'button', 'onclick="tag(\'strong\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'em', '', 'I', '', 'button', 'onclick="tag(\'em\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'strike', '', 'Strike', '', 'button', 'onclick="tag(\'strike\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'p', '', 'P', '', 'button', 'onclick="tag(\'p\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'br', '', 'BR', '', 'button', 'onclick="tag(\'br\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'sp', '', 'SPAN', '', 'button', 'onclick="tag(\'span\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'break', '', 'Break', '', 'button', 'onclick="tag(\'break\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'img', '', 'Image', '', 'button', 'onclick="tag(\'img\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'link', '', 'Link', '', 'button', 'onclick="tag(\'link\')"', '', '', '', '', '', '', '', '');
echo html_input('button', 'include', '', 'Include', '', 'button', 'onclick="tag(\'include\')"', '', '', '', '', '', '', '', '');
echo '</p>';
Title: Re: Finaly, texy! for snews
Post by: Keyrocks on March 23, 2008, 06:28:44 pm
Do you know if there is an english language version of the source site?
Title: Re: Finaly, texy! for snews
Post by: Palmik 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.
Title: Re: Finaly, texy! for snews
Post by: Palmik 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?
Title: Re: Finaly, texy! for snews
Post by: funlw65 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;
Title: Re: Finaly, texy! for snews
Post by: Palmik 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 (http://img368.imageshack.us/img368/5590/commentboxsg3.gif).
Title: Re: Finaly, texy! for snews
Post by: funlw65 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.
Title: Re: Finaly, texy! for snews
Post by: Palmik 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.
Title: Re: Finaly, texy! for snews
Post by: funlw65 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.
Title: Re: Finaly, texy! for snews
Post by: Palmik 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 (http://palmik.net/domov/zmeny/)[/code]
Title: Re: Finaly, texy! for snews
Post by: funlw65 on March 25, 2008, 11:35:53 pm
(http://lh6.google.com/funlw65/R-l8BFwM8uI/AAAAAAAADM0/2w4t-ZadhiY/s400/texycomment.png)

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 (http://picasaweb.google.com/funlw65/Parser/photo?authkey=fDL4uQ0ohFQ#5181855190647370498).
Or you can use Wordpress for your Texi! .
Title: Re: Finaly, texy! for snews
Post by: Palmik 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)
Title: Re: Finaly, texy! for snews
Post by: funlw65 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...