[prev in list] [next in list] [prev in thread] [next in thread] 

List:       quanta
Subject:    [Quanta] HTML blocks or include files, revisited
From:       Mike Evans <mikee () saxicola ! idps ! co ! uk>
Date:       2005-11-15 16:46:02
Message-ID: 200511151646.02668.mikee () saxicola ! idps ! co ! uk
[Download RAW message or body]

> On Monday 27 June 2005 16:26, Holger Zebner wrote:
> > To my knowledge, Quanta doesn't have that feature exactly.  But as
> >  you said, it's basically just a complex search and replace.  So
> >  what's to stop you from doing it that way?
>
> If you imagine a news item or something like that which changes often
> thenit would be nice to be able to change just the file which
> contains the news and not to define the search&replace.
> Just a tool to speed things up.

Part of the reply from Andras
>The fact that Quanta doesn't do it right now (for several reasons, one 
>being that SSI is better, safer), doesn't mean that you cannot extend 
>Quanta to do it, if you know some scripting language. bash and some 
>extra tools (sed, grep, awk) might be enough, but python, perl and so 
>is also good. What you would need to do is to define your own rules 
>where a template begins and ends, like you said:
><!--INC:"myblock.inc","13.06.2005 00:06:22"-->
>BLOCKTEXT
><!--/INC:"myblock.inc"-->


>What is more interesting is to write a script that detects if the saved 
>file is myblock.inc and grep through the project files and update all 
>of them. The procedure is the same: write the script, create a script 
>action, assign it to the save event.

I have mostly written a bash script to do what's wanted here, (I think), using 
DCOP to copy and paste from sources files into the space between 
<!--INC:"myblock.html"-->
and
<!--/INC:-->


I'll post the script when I've finished commenting/debugging it but here's the 
section that does the work.  Some lines will have wrapped.

---snip---
# Open the required file(s)
dcop quanta-$PID WindowManagerIf openFile $PROJECT/$TEMPLATES/$INFILE 0 0
INFILE_IF_NUM=`dcop quanta-$PID WindowManagerIf currentEditorIfNum` 
#echo "infile if num = $INFILE_IF_NUM" #debug
# Select and copy the file contents
dcop quanta-$PID SelectionInterface#$INFILE_IF_NUM selectAll 
dcop quanta-$PID ClipboardInterface#$INFILE_IF_NUM-$INFILE_IF_NUM copy 
dcop quanta-$PID ViewCursorInterface#$IF_NUM-$IF_NUM setCursorPosition 
$L_START 0
# Now paste at the cursor position
dcop quanta-$PID ClipboardInterface#$IF_NUM-$IF_NUM paste 
# Clear the selection in the source file
dcop quanta-$PID SelectionInterface#$INFILE_IF_NUM clearSelection 
---pins---


It deletes the old content first so it can also be used to easily update your 
page.  It works fine but I cannot find a DCOP method to return the focus back 
to the updated page, it stays with the last loaded page.  Have I missed it or 
is there no method to set the focus to a named/numbered editor window?


-- 
Mike Evans


GPG Key: 1024D/050895C2
_______________________________________________
Quanta mailing list
Quanta@mail.kde.org
https://mail.kde.org/mailman/listinfo/quanta
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic