I'm working on a bundle command (see below) that converts a plain-
text document (screenplay) to a PHP file for conversion to PDF via
FPDF (http://www.fpdf.org). Everything is working just fine except
for two things I just can't figure out--for the record, this code was
given to me by Allen for an HTML conversion and I've repurposed it
for this.
The first problem I'm having is with the very last line of code. The
idea is to get safari to open the generated document in Safari and
process it as a web-page. Because $DST seems to output the file-path
I can't just have it open "http://localhost/example.php", which is
what I want. How do I do that? Is it in the manual, 'cause I missed
that part.
The second question is regarding the 19th line of code:
$this->Cell(5.5,.18," XXXX ",0,0,'L',0);
I want to know if there is a way to define the "XXXX" bit in the
document itself with something like:
$header = example
How would that be done?
Thanks in advance, you guys are really helping make this bundle kick
butt.
-------------------------------
# first figure out a name for the result
NAME="${TM_FILENAME:-untitled}"
BASENAME="${NAME%.*}"
DST="/Library/WebServer/Documents/$BASENAME"
# everything we output within { … } is written to the PHP file via
redirection (see line with the })
{
# first output PHP header
cat <<HEAD
<?php
require("fpdf/fpdf.php");
class PDF extends FPDF
{
//Page header
function Header()
{
//Move to the right
\$this->Cell(5.5,.18," XXXX ",0,0,'L',0);
//Title
\$this->Cell(.5,.18,\$this->PageNo(),0,2,'R',0);
\$this->ln(.32);
}
}
\$pdf=new PDF("P","in","Letter");
\$pdf->SetMargins(1.5,.5,1);
\$pdf->AddPage();
\$pdf->SetFont("Courier","",12);
HEAD
# then PHP body (converted from document)
perl -pe '
s/"/\\"/g; #escape quotes
s/\/\/(.*)\/\/|^\/\/(.*)//g; # strip out non-printing comments
s/^(\t{4})([^\t].*)$/\$pdf->Cell(2);\$pdf->MultiCell(0,.18,"$2",0,L,
0);/g; #characters
s/^(\t{3})([^\t].*)$/\$pdf->Cell(1.5);\$pdf->MultiCell(1.5,.18,"$2",
0,L,0);/g; #parenthetical
s/^(\t{2})([^\t].*)$/\$pdf->Cell(1);\$pdf->MultiCell(3.5,.18,"$2",
0,L,0);\$pdf->ln();/g; #dialogue
s/(\t{10})([^\t].*:)/\$pdf->Cell(4);\$pdf->MultiCell(2,.18,"$2");\
$pdf->ln();/g; #right-transitions
s/^\w+.{2,20}:\s*$/\$pdf->MultiCell(0,.18,"$&",0,L,0);\$pdf->ln();/
g; #left-transitions
s/^(\w|\.|\[|\-).*$/\$pdf->MultiCell(0,.18,"$&",0,L,0);\$pdf->ln();/
g; #paragraph
'
# and finally PHP footer
cat <<'TAIL'
$pdf->Output();
?>
TAIL
} >"$DST.php"
# open the generated PHP file in Safari
open -a Safari "$DST.php"
Dear List,
One of the most striking things to a new user is that the most
important part of the UI for textmate is a button a that is at the
_base_ of the window (v. unexpected) and that is the smallest part of
the UI. I'm quite sure I would not have realised its significance had
I not seen the Screencasts, and I know that people I've recently
introduced to Textmate have had the same problem. Is there any way it
could be made more obvious?
Best,
N.
What is the meaning of the "swallow" key for language rules? I
searched the archives, wiki and documentation but I couldn't find a
good definition. Did I miss something?
--
-Corey O'Connor
> I'm guessing you want it to replace all " with \", in which case
> you would want to escape the \, i.e. s/"/\\"/g
Yeah, I feel silly, that's just it.
And one of these days I'll tell you everything I want to do, I promise.
[There is a question in here... scrub through to the end!]
This is very interesting!
Clearly, folks have a range of different tasks they need to
accomplish and a range of different approaches for doing so.
In my case, what I'm currently doing is ridiculously simple compared
to what some on the list are doing: I'm just editing a small number
of files that make up "a website." I'm editing the files locally...
the files are on a hard drive in a box that's right under my desk.
But to complicate things, I want to be able to see how these files
appear when served from a REAL web server (not just opened from my
disk). Plus, I also want to know how they look from a Windows machine.
So... I've set up my next oldest computer (a G3) as a "server in my
closet." This is my "test" deployment location.
Of course, I also want to deploy the files on a (external) "staging"
server where my client(s) can check things out.
So, at minimum, I have stuff in three places that I (usually) want to
be the same. When I started using TextMate, I was concerned about
that lack of "ftp/sftp/ssh integration."
After I discovered and researched rsync (yes, consider me a newbie as
regards The Power of the Command Line) and TextMate bundles, I'm
suddenly no longer concerned about whether I can open a file "via
ftp" FROM WITHIN TextMate. Or save it back from TextMate "to" the
Internet.
On Feb 19, 2006, at 10:05 PM, Court K wrote, in part:
> <snip>
> I mean who actually is editing files that ARE NOT going to end up
> on the internet? ...
> <snip>
As other's have mentioned, this is not *quite* the universal
situation... for example, folks editing LaTeX are (I presume) mostly
expecting to see the result in print; folks using TextMate to write
screen plays are also (again, I presume) thinking in terms other than
"web deployment."
The files I am editing ARE intended to go directly for the Internet.
But still I feel no need for "built-in" ftp/sftp/ssh support in
TextMate. In part this is because I'm always working with the same
set of files and their location on the net is always the same. And
no one else is editing them other than me.
So my Question:
What are folks doing that makes them want to see built-in ftp/sftp/
ssh support in TextMate? One situation I can imagine is the desire/
need to open many arbitrary files that are located in many arbitrary
locations on the Internet. I don't have a good picture of when
anyone would be needing to do that though. Are people doing that?
For me, the files I want to edit are on my computer. Periodically
they need to be uploaded to the net, but my editing sessions don't
begin from copies that were on the net.
Just Curious! ;)
eo
As a follow-up to the discussions about remote file editing, I wanted
to throw another idea out there. First of all, I think the ideal
solution is to have Mac OS X mount a remote directory in the Finder,
and then access that directory from TextMate as if it were on a local
volume. (After all, providing file access is the operating system's
job; TextMate shouldn't have to implement special support for it.)
I mentioned WebDAV before, and for editing files on a web site, it's
usually the best solution. Unfortunately, accessing remote files
outside of the web server's control is very difficult, sometimes
impossible, with WebDAV. For those cases, I've been resorting to NFS,
which Mac OS X also supports natively. However, NFS has always been
buggy in my experience, at least when accessing it across the Internet.
Luckily, Mac users have a third option: the Apple Filing Protocol, or
AFP. Although it's becoming obsolete in favor of less proprietary
standards, it doesn't suffer from the weaknesses of WebDAV and NFS.
Namely, it's not bound to a web server, and it has no trouble
mounting remote directories over the Internet. I've been using it to
edit remote shell scripts in TextMate with no problems.
Setting up AFP is very easy if your host system is Linux and you have
admin rights. You simply install the netatalk package [1] and start
the AppleTalk daemon. For instance, if you're running Fedora Core:
yum install netatalk
service atalk start
After that, you simply go the Finder, choose Connect To Server, and
enter afp://myserver. You can then enter your user name and password
to mount your home directory. More info about configuring share
points and enabling secure authentication is in the netatalk
documentation.
Anyway, I just wanted to mention that option for those of you who
want remote file access without having to rely on a third-party
utility or wait for SFTP support to be built-in to TextMate.
Trevor
[1] http://netatalk.sourceforge.net/
Howdy y'all. Wooo doggies!
I know a lot of people have talked about this in the past, but...
If you want to use TextMate through FTP, you can still use a project
window with tabs.
#1 Open up your FTP add (I've used Cyberduck and Transmit)
#2 Open a document from your FTP program into TextMate (cmd-j in the
duck)
#3 Find the temp folder that your FTP app uses to save the files
you're editing (the duck uses /var/tmp/folders.503/TemporaryItems/ on
my system)
#4 Open that folder in TextMate
#5 Close any FTPd files you're currently working on
#6 Open a document from your FTP program into TextMate (cmd-j in the
duck)
Your temp editing FTP files should now pop up as new tabs in textmate.
For extra slickness, you can save this project, stick the .tmproj in
your dock or something and be ready to go at a moments notice !!!!
yee haw!!!!
Enjoy ;)
(this really shouldn't come as news to anyone, but it was fun to feel
like a big know-it-all for a few precious moments)
((back to cruel intellectual mediocrity))
Hi all,
Just put this together and thought I'd share:
$TM_SELECTED_TEXT`echo "$TM_SELECTED_TEXT"|ruby -00 -pe
"gsub(/([._]|\W)(?:
(x)|(y)|(X)|(Y)|(width)|(height)|(w)|(h)|(Width)|(Height))/) { \$1 +
(\$2 ? \"y\" : \$3 ? \"x\" : \$4 ? \"Y\" : \$5 ? \"X\" : \$6 ?
\"height\" : \$7 ? \"width\" : \$8 ? \"h\" : \$9 ? \"w\" : \$10 ?
\"Height\" : \$11 ? \"Width\" : \"\") }"`
It will take, for example, something like this:
var xMin = (this.trap_mc) ? this.target_mc._x - bounds.xMin : 0;
var xMax = (this.trap_mc) ? this.target_mc._x + this.target_mc._width +
(this.trap_mc._width - bounds.xMax);
And append this afterwards:
var yMin = (this.trap_mc) ? this.target_mc._y - bounds.yMin : 0;
var yMax = (this.trap_mc) ? this.target_mc._y + this.target_mc._height
+ (this.trap_mc._height - bounds.yMax);
This is something I do by hand like, maybe 10 or 20 times in a coding
session. Anyone else have some useful additions (or a more elegant
regexp)? ;)
- Ben
___________________
Ben Jackson
Diretor de Desenvolvimento
ben(a)incomumdesign.com
http://www.incomumdesign.com
Anybody know any commands in Textmate that can remove all extraneous
whitespace from a HTML document like BBEdit's Formatting->Compact function?
I checked the tidy documentation but couldn't find anything. Strange, I
thought Tidy would have that one.
Quinn
I'm getting a digest of the topics here and suddenly (about 2 days
ago) I started getting every message posted here listed twice (in a
row) in the digest. Any one else having this problem? Any suggestions?
— oliver taylor
ollieman.net