morning all!
Corsix: any idea about the whereabouts of cwgordon7?
dmitrig01: no :|
:(
anyone using teamspeak ? i'm connected and find it strange to be the only one in the channel there
teamspeak?
Download teamspeak at http://teamspeak.com/index.php?page=downloads | To connect, use "webavant.com:8768" as the servername, and your preferred nickname with no password. | If you are on Mac watch this screencast: http://dmitrizone.com/dump/teamspeak_for_mac.mov | More info at http://groups.drupal.org/node/4944
wait, 6pm UTC? Wasn't it 7?
Yeah, it's 7 pm UTC
http://www.macupdate.com/info.php/id/19678
cwgordon7!
11am PST is right, though
I think...
http://groups.drupal.org/drupal-dojo is saying 18:00 GMT
Does that need to change?
but I swear it was 7
yup: that's what I get in google calendar too
ok, 7 it is.
I prolly messed it up
"2 eastern us time, 7 gmt."
In the body of the node
http://groups.drupal.org/node/7998 - bottom say 7pm, top says 18:00
dmitrig01: http://www.savvy.nl/blog/
Senpai: new version?
it is
last post is January 29th, 2006
yeah, but my version is still a beta2
It's 17:58:11 right now
I must have gotten it from a different source
me too!
"TeamSpeex 1.0 Beta 2
November 14th, 2005"
dmitrig01: told ya
no wonder, huh?
should learn to always go ti the source
Corsix, cwgordon7, thestart time has been fixed. http://groups.drupal.org/node/7998
http://groups.drupal.org/node/7998 => Lesson #39: Flexifilter, the most awesome thing to hit Drupal since the potato => 5 IRC mentions
Senpai: :)
Corsix: I want to release a 1.0 before the lesson starts
see you in one hour, then :-)
Corsix: It's pretty much ready to go, right?
cwgordon7: PM
Corsix: cwgordon7: I think there shoud be a hook_flexifilters that allows modules to define flexifilters
dmitrig01: There definitely should be
dmitrig01: 6.x-1.1
It'll have to wait, I think
I would prefer hook_default_flexifilters
whatever, the name doesn't really matter ;)
vis a vi views
Import/export features are awesome and high on the list of features, right, Corsix?
where modules can define views which you then make instances of
which go along with import/export
RobLoach: watching your screencast - LOL @ "This is a very powerful framework so we should use it"
aclight: ping
osinet: pong
just saw you appear and disappear on teamspeak
any idea whether this is the proper way to connect ? I'm not familiar with that client
yeah, had to reboot
Note that neither myself nor cwgordon7 have microphones, so we won't be on TS
i think so. ive only used it once before though
oh...no teamspeak.. bummer
Corsix: ok
Corsix: do either of you have headphones?
I do
I do
so I could listen in
use that as a microphone
it sometimes works
headphones have speakers on them, not a microphone
... no... not these headphones...
since a headphone is a reverse microphone
Corsix: it's the same thing...but on analog only
Corsix: cwgordon7: How do you expect to do the lesson without a microphone?
the sound won't be as good usually
just wondering :D
We have presentations planned
cwgordon7, Corsix: Does this look right to you? "Join us in 15 minutes at the http://webavant.com/dojo1 training room for a lesson all about the brand new FlexiFilter module. No, you haven't heard about it before. Like we just said, it's brand new!
What is it, you ask? Imagine this. You and your site administrators can new create and control all kinds of filters throughout the site without having to code a single line. Oh, and yes, it also has a API for other modules to tie into. Cool!"
do they talk to us?
aclight: In a manner of speaking
Senpai: Yep, looks good.
cool
Nobody told me a microphone was needed, and I hadn't even heard of dojo until last week, so don't look at me
lol
ok, email is away
cwgordon7: Corsix: you guys ready
Ok, we're ready.
Corsix?
yeah
The presentation will be at http://docs.google.com/TeamPresent?docid=dg79fhm9_1233r4xfcg
If you want to try stuff out as we go along, have a drupal 6 install with flexifilter 6.x-1.0 handy
There is a longer presentation that will not be used during this lesson but that you can use as a reference at http://docs.google.com/TeamPresent?docid=dg79fhm9_1cfbhbddj
Everyone will need to join the first presentation at http://docs.google.com/TeamPresent?docid=dg79fhm9_1233r4xfcg and we'll begin
Corsix: That google docs link seems to be 404
hey sorry bout the audio being broken
webavant!
the web player works now
Ok, everyone we're starting
ok, you should be seeing the first slide on the google presentation
Click "follow presenter" to follow me.
dmitrig01: Yeah, I have strange ways of describing it......... You mind putting the link up in the DruJo?
cwgordon7: "it can do anything!" can you write an extension to make it replace views?
RobLoach: :-P
*it = things
dmitrig01: I'm sure you could have it tie into views
Is the text box working?
I'm totally confused. I understand we're not doing VNC, but we are doing a docs.google.com presentation. But where's the presentation, if there's no audio? Are we just each paging through the slides?
and me & cwgordon7 will be talking through the slides here in IRC
We'll be going through the slides, we'll be explaining them as we go
oh
I have stuff to copy-and-paste into here
now it's making sense
Is anyone unclear on what flexifilter is supposed to do?
utterly
no idea
me neither
LOL
Ok then
LOOK at the slides
(There is no audio, folks. Just follow along in IRC)
Flexifilter lets you create custom filters
Are we on slide #2 then?
Yes
Click "follow presenter"
To stay on the correct slide (the one I'm on)
I don't see a "follow presenter" option.
where do we click that?
top right
unless you are already following
The right hand window on both screens I have it up on says "Not Found" Error 404.
it says no one is currently presenting
right now, it says there is no presenter
I see the slides, but nothing useful in the right-hand pane.
ah, came bak
It should say "You are following the presenter." in the top right
or a link to do so
ok now...
** And we are starting **
Thank you, Corsix
Why don't you jsut type this in google so we don't have to switch windows?
Basically, you can define your own filters through the user interface
Because this is where stuff is logged
So instead of having to create a custom module for each filter you want
you can make them through the UI
This will totally revolutionize how filters are done through Drupal
(hopefully)
If a filter already exists, is there any point in migrating it to flexifilter (I happen to have one in my g2 module)
Yes
Flexifilter allows you to hand a greater level of control to the users
well, to the site admins, which are the users in this case
They can choose exactly how much text to allow the filter to filter
They can change the format of the filtering
I gotta have a shower... I'll be back in about 10 minutes.
(instead of links encompassed in [[ ]], they can choose (( ))
Or whatever
That way they don't have to delve into the php code to do simple stuff like that
FYI, guys, there's no "follow the presenter" link in the right sidebar of that googld presentation. It jsut says 404 Not Found.
hm, bad link?
After refresh does it still 404 ?
http://docs.google.com/TeamPresent?docid=dg79fhm9_1233r4xfcg#
yes, it stil says 404
if so, we'll have to say when we switch slides,
in two different browsers
yeah, just announce the slide #
and put a black mark against google presentations
what about this one: http://docs.google.com/TeamPresent?docid=dg79fhm9_1233r4xfcg&pli=1
Ok, moving onto the terminology
(slide 3)
(slide 4)
We call these filters "Flexifilters"
which are created through the admin UI
and can be enabled or disabled
The reason you can only have 128 enabled at a time is because the filter module stores filter's deltas in a tinyint in the database.
(slide 5)
The basic building block is a component
That is our name for anything that you can put into a flexifilter
Components are the stuff that actually do things to the text
so it could be "do a text replace" or "do this while loop"
You can choose from a variety of components to add
And components can be added more than once
and by chaining these components together, you make filters
Any questions?
Ok, then, next slide
(slide 6 then)
Some components (if and while loops at the moment) can have conditions in them
which control when the if/while is run
A common condition to use is "does text contain phrase"
or "is text longer than..."
So basically, the components within which the conditions are contained are able to evaluate the condition and do something based on the evaluation.
(slide 8)
For example, an IF component contains a condition and components. The components are only executed if the condition is TRUE.
The simplist component is text replacement
Here we have a short list of simple components for use as examples
wow :)
this takes a phrase and replaces it another
For example, you can choose to replace all instances of "Google" with "<a href="http://google.com/">Google</a>"
(slide 8 now)
then you have appending and prepending, as named
Thereby rendering cuss words as asterisks, for instance?
Yep, that's another good example, Senpai
The possiblities are /endless/...
Sounds like it.
I'm not so sure what text slicing is though
cwgordon7, care to explain that one?
Sure
Basically, you can choose to drop the first few or last few characters of the text
cwgordon7: example?
This is useful, say, if using another component creates two characters of junk at the end of the text.
Yes please. Example. Why would you need to do this?
ahhhhh
(slide 9)
This sounds cool.
Workflow Control
like... username's blog on the blogs page?
Also, you could choose to slice off any characters after character 1000, which is the site-essay-contest's character limit
jacine: Not sure I understand your question
can you use wildcards on the text you're looking for?
There is regular expression text replacement
brenda003: you can use a regular expression
does it just do node content? or can it change the text of links and page titles?
Jacine: it's a filter
ahh, interesting.
it is a filter
jacine: It does anything that can be filtered
so node content
ok, thanks
Meaning nodes and anything else that uses filters
Such as profile textarea fields
etc.
(slide 10)
Two clever components are if() and while()
We touched on this before, if() and while() loops
they are used just like any other component
except that within them can be placed components and a condition
We can do conditional statements inside of filters now??????
Except they don't actually do anything themselves, but just fire other components that are placed in them.
so that the components within are executed if/while the condition is true
Senpai: Of course!
let's say you have the input : foo.mp3. Will flexifilter actually make it add a whole lot before and after the input? if that is what the admin wants?
Hausha: So long as you define what that should do, it can.
Hausha: You can write a filter like: if (text contains ".mp3") then append "xyz", prepend "foo"
moving onto slide 11?
Let's explain while() briefly
While() loops, like if() statements, have components within them
and a condition
A while() loop works pretty much like an if() statement, except it does actions while the condition is true.
This is slightly dangerous as it may cause an infinite loop
So, you can specify a limit at which it will abort
if you had: while(text contains "cheese") do nothing
then it would loop forever
so you have to set a limit
which defaults to 100 iterations
Continue to slide 11
cwgordon7: do you use any eval() statements?
but you could set to 9999999 if you know it will not loop forever
You can add php code as a component or a condition if you know what you're doing.
dmitrig01: So yes
shivers
Yeah, I can see how you could get an infinite loop going quite easily. Could someone white-screen a site by setting up a flexifilter while() into an infinite loop?
can you set the filter to act differently depending on if it's a teaser view, and other things?
Well, you have to specify the limit.
Senpai: which is the reason you must give a limit
brenda003: Not yet, we just had a 1.0 release half an hour ago ;)
after which it stops looping even if the condition is true
if you know what you are doing, you should be able to use the hooks
brend003: Not even sure if that makes sense
cwgordon7, me neither. :P
:D lol ok
(slide 12) then
No release planned for 5.x?
currently is 6.x
If anyone wants to backport, please post a patch
may backport it
shivers at the thought of 5.x ;)
if there is demand
but 6.x is the future ;)
See http://drupal.org/node/207629
http://drupal.org/node/207629 => Drupal 5 version! => Flexifilter, Code - Misc, normal, postponed, 2 IRC mentions
great
Now, slide 12
I wonder if there could be an error check that bails out after a preset time if, say, the $continue_until_finished flag was not set. That might protect newbs from themselves, while still giving power users the flexi that they need. I'm musing. We'll talk more after the lesson.
So, if and while can only contain 1 condition
however, that condition can be an and/or/not group
these and/or/not can contain multiple conditions
Correct
cwgordon7: can you make an ALL NOT?
Use the AND group to "and" things together
Use the OR group to "or" things together
So an AND condition will evaluate to TRUE if all the conditions within it are true
Use the NOT group to negate a statement
e.g ALL conditions have to be false for it to be TRUE?
ALL conditions become true or false
just as a shortcut instead of nesting an AND group in a NOT group
No, if any of the conditions are false, it's true
Any questions? comments? concerns?
If you look carefully, then the NOT group is in fact a NOT AND group
but if you only put one condition in it, then it is NOT
what will happen to modules like bbcode
Slide 13, then
Thus far, I'd have to say the power this module brings to bear on our content is nothing short of phenomenal!
"ANY of the conditions are FALSE"
Senpai: this will be on drupaldojo.com no matter what :P
jeally-bean: they should vanish
dmitrig01: Yeah, we'll get the presentation and post it
(slide 14)
jeally-bean: because BBcode will take two seconds to implements
Senpai: no, I mean the module
two very common conditions
dmitrig01: oh! hahaha
text contains phrase/regex
and text length
so that you can cause things to happen only when the text contains a certain phrase
or exceeds a certain length
or using NOT, when these things don't happen
For example, you could choose to append a "back to top" link if the length is greater than 1000 characters.
Or whatever
cwgordon7: could you make a back to top every 1000 characters?
in a creative way, yes
dmitrig01: If you wanted to...
LOL how?
oooo! We could use these simple expressions, and package up a pre-built set of them for Advanced Forum users, for esample, so that they'd have a series of presets much like BBcode.
Senpai is a genius
I love this module
me too :)
Senpai: we need to get it a hook()
So flexifilter could replace http://drupal.org/project/spamspan module in notime (just as an example) ?
import/export features are reserved for 6.x-1.1
If you love this module you'll love cwgordon7 and my next module
and thats for another lesson
whose name, whereabouts, and functionality will be kept secret :)
Ok, onward then
Chunks are something really cool
They're awesomeful!
they allow you to extract part of the text and apply a set of components on just that bit
This module could replace http://drupal.org/project/reptag too :)
It will replace every single filter module within two months ;)
haha :D
so you could take every part of the text "<bbcode>whatever</bbcode>"
and run BBcode filters on just the bit inside
You're gonna have to explain Chunks by giving an real-world example. I don't get it yet.
cwgordon7: how would you replace geshifilter?
aclight: How does geshifilter work?
holy crap this is awesome.
cwgordon7: geshifilter uses the external geshi library
cwgordon7: that's what's used to do syntax highlighting for languages
aclight: geshifilter would implement the hook
So geshi filter would implement the hook
aclight: and add a new component
(slide 16)
"higlight text"
language would be configurable
So to use Chunks, there is a basic Chunk Grabber component
then you could use a chunk grabber
which like IF and WHILE, has components within it
And perfect for SEO too!
to grab everything between <javascript> and </javascript> and run it through the geshifilter component
but unlike if and while, runs the components within ONLY on certain parts of the text
For example, you can grab any text within <myfiltertag> </myfiltertag>
And run it through the subcomponents of the chunk grabber
Or within [[ ]]
Or whatever
It will run the components within once for each chunk grabbed
So we can make custom tags, wrap certain content in those tags, and only act on it during a while() ?
You don't need a while
but you could...
It will run its subcomponents once for each tag
you could
saw-weet!
So if you have [[abc]] [[123]
er [[123]]
It'll run abc and 123 each through the filter once
So you could set a chunk as "[[...]]"
and within the chunk, append "google"
so "[[abc]] [[123]]"
would become "[[abcgoogle]] [[123google]]"
Well, the [[ ]] tags would disappear, actually
Corsix: could you take out the [[ and ]] part?
Yeah, they'd disappear by default
But they can be set to reappear
Flexifilter. Now with auto-stripping!
indeed
We have a cool chart on the next slide
Senpai: LOL
And before you judge too harshly, I was using Windows "Paint" to make it
ok, slide 17
skipped ahead and was already reading it
shows an example of Chunk Grabbing
This will take links in the form of [link:title]
cwgordon7: [http://drupal.org/:Drupal!] won't work :o
(although this particular example could also be implemented using regular expressions)
Corsix: :P
I know...
It's just an example, ok? ;)
sure, but Chunks sounds cooler-er
isn't there a way to use an api function instead of just the flexifilter mechanism. In that example, for instance, invoker url() on the "title" chunk instead of building the link by hand
and they can do things that regexs cannot
osinet: yes
osinet: you can make a new component
osinet: of course
osinet: two ways
osinet: (1) Define a new component
osinet: or you can evaluate PHP code
osinet: (2) Manually use php code
beat cwgordon7 to it
dmitrig01: grrr
:P
ideally, you would create a component
ON with the presentation
but simply inserting PHP would do the job, albiet hackily
That's it...
Now we move onto the API discussion
So, flexifilter has two hooks
For anyone interested in further detail, look at http://docs.google.com/TeamPresent?docid=dg79fhm9_1cfbhbddj#
one to provide flexifilter with additional components
and one to provide it with new conditions
http://drupalbin.com/471
One will be added in the near future for importation of flexifilters ;)
shows a simple example of the component hook
it returns an array of components
with each component having a name, callback and group
and other optional things, like description and callback arguments
http://drupalbin.com/472
adds the component callback
So hook_flexifilter_components lists the components
and each component is implmented in a function
the function is similar to hook_filter
in that it as $op and $text
default: return $text; is not really necessary, though, right?
thx for the presentation
You could just add return $text;, right?
when $op is "settings", you should return an forms API array
for op of "prepare" / "replace", you do whatever the component is ment to do
You mean "prepare" / "process" ?
yeah, prepare and process
as filters are run in two stages
the prepare stage and the process stage
A "prepare" stage that escapes stuff and a "process" stage that does stuff.
and for any $op that you don't do anything for, you should return $text
Prepare is run first, and then process.
http://drupalbin.com/473
Extends the previous code with some settings
Unless it's 'settings' in which case you should return an empty array
so when you add the component, you can configure it
in this case with a dropdown menu
but you can put in a full forms API array
when you come to handle prepare and process, the values from that form are available in $settings
(pretty neat, isn't it?)
12:00 PM cwgordon7: can you give a use case of prepare/process?
if you've got the line break filter turned on
but you want part of the text to be unaffected by it
(say anything between <?php and ?>)
In your invocation of the hook, you define the step in which it takes place, either 'either', 'both', 'prepare', or 'process'
If it's 'both', It will be run in both prepare and process
then in the prepare, you would escape all the newlines between <?php and ?>
still doesn't get it
dmitrig01: Basically because real filters use it
LOL
So to make it easier for stuff to be ported, we have a 'prepare' and 'process' step
But basically it breaks filtering into two stages
If you want to do different stuff, go ahead.
Most everything will be done in 'process'.
Everything is invoked in "prepare"
and then again in "process"
Setting 'step' => 'either' defaults to "process", and the user can only change it if they check the "I know what I'm doing" box
The second hook is hook_flexifilter_conditions
Corsix: Do you have a conditions example?
ah, ok
http://drupalbin.com/474
So like components, you return an array
but instead of components, you list conditions
http://drupalbin.com/478
and again, you then write a function for each condition
which like components, has an op of settings, prepare or process
although for all intents and purposes, you can treat prepare and process as the same in conditions
less you want to write a "is the prepare step" condition
So conditions take the text, and should return true or false
(which is already written for you)
So, anything that you cannot do with flexifilter at the moment
write a component or condition so that you can it
(Which is very little)
and then share it with us!
You can either write your own module or we can incorporate it into the flexifilter core.
You guys will have to pastebin all the code example into one doc at the end of the lesson, so I can place a single drupalbin link on drupaldojo.com.
Senpai: cool, will do.
Senpai: Add a link to the full presentation, too?
Already did
http://drupalbin.com/479
is both parts
An example module that works under the flexifilter framework is at http://drupal.org/project/flexifilter_cite.
If anyone's interested
Great lesson, guys! Thanks for the info. It's cool seeing the future of Drupal!
<<-- Return to the lesson page