Hello,
I've been a lurking member of this list for some time, but this is my first attempt at posting. I've been trying out TextMate in demo mode and plan to buy it because it's nearly perfect for the way I work, but I have a couple questions I'm hoping somebody could clear up for me.
I'm not a programmer, so please forgive me if my questions seem somewhat elementary. I do, however, use the Terminal quite often for shell commands, and I understand PHP well enough to write code for my own purposes. I prefer coding my web pages by hand, and I'm fluent in XHTML and CSS and competent in XSLT. I'm a bit anal about clean coding, usability, and accessibility (both for the end user and for me when writing my pages). For these reasons among others, I've been disappointed by virtually all of the website generation applications and/or scripts I've tried. It seems they require lots of convoluted configuration that just gets in my way. Besides, I'd rather just do it all myself with flat text files, using scripting just to generate the headers, footers, navigation, etc.
I'm not necessarily concerned with TextMate's ability to do the many super-complicated things it obviously can do, as I probably won't use most of it myself. However, I'm wondering if it has a feature similar to the Persistent Includes available in BBEdit. I have examined the manual and read about how to use snippets, templates, commands, and the like, and I understand how these could be used to make my life easier. The problem is that I haven't figured out if there's a way to re-parse an entire project or certain files within a project after I've made changes that will affect the output.
For instance, if I've used a script to output links to all the files contained in the directory (as a navigation menu of sorts) but later add more files to that same directory, I'd like to be able to re- generate the entire site so that those new files show up in the menu. Likewise, if I've generated prev/next links to other files in the same directory, I'd like to have them updated without having to manually type the new hyperlinks into each and every file of the site. I know I could use PHP or server-side includes or something similar (and I have written a simple php function to do just that), but I'd really like to generate static web pages because having dynamic pages online really isn't necessary for what I'm doing (also, I can upload the same files both to .Mac and to my virtual host, for example).
If nothing resembling Persistent Includes is available in TextMate, another viable option would be to auto-generate the output of an entire project but save it to a new directory on my system using the same hierarchy of the original project. That way, I can simply re- generate it whenever I need to. In fact, that would probably be a simpler solution than the Persistent Includes idea, but of course you all probably know much more about how to efficiently accomplish this than I do. Also, if anyone could point me in the direction of a good streamlined tutorial on how to use shell scripts in an environment such as TextMate, perhaps I can figure it out on my own. The TextMate manual is nice, but something more tutorial-like would help a lot.
Sorry for the long post - it actually started out longer with more details about my background and what I do, but I figured people may get annoyed, so I cut it. If I need to further clarify exactly what I need to accomplish, please ask, but I suspect most of you are quite familiar with BBEdit and know about how Persistent Includes work and how they differ from regular Includes.
Thanks,
Crystal
hi.
Am 02.03.2006 um 15:30 schrieb csilver_junk@mac.com:
I'm not necessarily concerned with TextMate's ability to do the many super-complicated things it obviously can do, as I probably won't use most of it myself. However, I'm wondering if it has a feature similar to the Persistent Includes available in BBEdit. I have examined the manual and read about how to use snippets, templates, commands, and the like, and I understand how these could be used to make my life easier. The problem is that I haven't figured out if there's a way to re-parse an entire project or certain files within a project after I've made changes that will affect the output.
For instance, if I've used a script to output links to all the files contained in the directory (as a navigation menu of sorts) but later add more files to that same directory, I'd like to be able to re-generate the entire site so that those new files show up in the menu. Likewise, if I've generated prev/next links to other files in the same directory, I'd like to have them updated without having to manually type the new hyperlinks into each and every file of the site. I know I could use PHP or server-side includes or something similar (and I have written a simple php function to do just that),
i think you could call this php-function from within a TM-command to generate the links and (at least) pipe the output into pbcopy (and the replace the static html by hand) or substitute the current selection.
regards, niko.
On 2/3/2006, at 15:30, csilver_junk@mac.com wrote:
[...] If nothing resembling Persistent Includes is available in TextMate, another viable option would be to auto-generate the output of an entire project but save it to a new directory on my system using the same hierarchy of the original project [...]
I have no real idea about what the Persistent Includes can do, but it would be easy to create a TM command which e.g. pipes each *.php file in your project through PHP and wrote the result to an “html” sub- directory (as an HTML file):
cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}" mkdir -p html for f in *.php; do php <"$f" >"html/${f%.*}.html" done
This would allow you to use all the power of PHP and create static files from that. You could add a master.inc which got sourced when generating each of the files, e.g. like this:
cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}" mkdir -p html for f in *.php; do cat master.inc "$f"|php >"html/${f%.*}.html" done
That way you could place shared variables and such in your master.inc.
FYI the TextMate manual is generated in a slightly similar fashion, see http://lists.macromates.com/pipermail/textmate/2006-February/ 008160.html for more.
Spell checking as you type seems to work for strings but not comments as the manual seems to indicate. Also does the same think in C++. Is this a genuine bug or have I screwed my setup?
I am using v 1.5
Dave.
On 3/3/2006, at 18:23, Dave Baldwin wrote:
Spell checking as you type seems to work for strings but not comments as the manual seems to indicate. Also does the same think in C++. Is this a genuine bug or have I screwed my setup?
The manual is wrong. We/I tried to have spelling enabled in comments, but since a lot of comments are actually commented out code, it got irritating.
On 3 Mar 2006, at 17:37, Allan Odgaard wrote:
On 3/3/2006, at 18:23, Dave Baldwin wrote:
Spell checking as you type seems to work for strings but not comments as the manual seems to indicate. Also does the same think in C++. Is this a genuine bug or have I screwed my setup?
The manual is wrong. We/I tried to have spelling enabled in comments, but since a lot of comments are actually commented out code, it got irritating.
That's a shame - it would be an acceptable irritation to me. If you care you could always use =begin =end in Ruby or ## to comment out code that doesn't need to be spell checked. As an aside this would be a good convention when command / is used to comment/uncomment code to avoid removing genuine comments when the code is later uncommented.
Just an observation :-) In Ruby you can but code in strings so doesn't this irritate you?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
On 3/3/2006, at 19:22, Dave Baldwin wrote:
Just an observation :-) In Ruby you can but code in strings so doesn't this irritate you?
The system is granular enough to have it disabled again for code in strings.
As for using =begin/end for code blocks, if that’s what you do, you can enable check spelling as you type in your version of TextMate for comment.line.*.
But it’s not easy to find a “works for all people and languages” setting that doesn’t have false positives wrt wrongly spelled text. So the better default is just to not have it do check spelling as you type for comments.
This is a neat approach but I see some limitations in it if I were to try to use it in the way I envision working. That is, I have a wish list! :)
As near as I can understand this code, it starts in the current TextMate project directory, creating a new directory there named "html." It then goes through the project directory looking for files that end in ".php," hands those files to the php command line interpreter and puts the output into the previously created "html" directory, changing the file extension from ".php" to ".html."
I assume it does this recursively both when searching for php files and when outputting the files as html. I think the -p switch will cause that to happen on the output side, but I'm not clear where it happens in the for...do part.
I don't see that this will create a complete site, though. That is, there are many other kinds of files (css files, image, movie and sound files, etc.) in my working site (my TM project). Naturally, those would need to get moved into their correct locations in the new (static) "html" folder also.
Next challenge: this process (ejecting a static version of my dynamic working site) is not something that I would do once, at the "end" of a project, but quite often... whenever I wanted to publish the site to a test or staging server. In that situation, I certainly don't want to have to process every file for the entire site each time I want to update my test server. I only want to process the files that have *changed* since the last time I ran the process. Conceptually, I sorta would like to work rsync into the process here, but I don't quite see how to do it (as none of the html files in the static site are going to match with their "source" php files).
Thanks for any ideas!
eo
On Mar 3, 2006, at 8:29 AM, Allan Odgaard wrote:
On 2/3/2006, at 15:30, csilver_junk@mac.com wrote:
[...] If nothing resembling Persistent Includes is available in TextMate, another viable option would be to auto-generate the output of an entire project but save it to a new directory on my system using the same hierarchy of the original project [...]
I have no real idea about what the Persistent Includes can do, but it would be easy to create a TM command which e.g. pipes each *.php file in your project through PHP and wrote the result to an “html” sub-directory (as an HTML file):
cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}" mkdir -p html for f in *.php; do php <"$f" >"html/${f%.*}.html" done
This would allow you to use all the power of PHP and create static files from that. You could add a master.inc which got sourced when generating each of the files, e.g. like this:
cd "${TM_PROJECT_DIRECTORY:-$TM_DIRECTORY}" mkdir -p html for f in *.php; do cat master.inc "$f"|php >"html/${f%.*}.html" done
That way you could place shared variables and such in your master.inc.
FYI the TextMate manual is generated in a slightly similar fashion, see http://lists.macromates.com/pipermail/textmate/2006-February/ 008160.html for more.
what you're trying to achieve is called make :) or, at least, a friendly frontend to it.
According to Eric O'Brien:
time I want to update my test server. I only want to process the files that have *changed* since the last time I ran the process. Conceptually, I sorta would like to work rsync into the process here, but I don't quite see how to do it (as none of the html files in the static site are going to match with their "source" php files).
Use make, that's exactly its "reason d'être".
.php.html: php ${.OODATE} > html/${.TARGET}
(in BSD make, GNU has a somewhat different syntax)
Actually, the concept of using a _dynamic_ tool to build static sites has just become of interest to me!
Until recently I only had to be concerned with the theory of building a web site. Now I'm faced with building a couple of small, but real, sites. Just the other day, I changed the name of one of the main html files and realized I'd also have to change the text where that file was linked in all the navigation menus that existed on every page. Gaaa! "Where is the 'include' functionality in HTML?"
Well, of course that's not where it is. The site I want to deploy isn't really "dynamic" at all. I just want the convenience, when I'm building it, of having repetitive parts that are common to many pages located in only ONE place.
While I don't know PHP, I bet I can figure out how to get include() to work for this simple case. So Allan's recent suggestion of how to process a PHP site that results in a static site was very interesting. I suppose you could use any kind of "preprocessor" that you wanted.
(By the way, "Persistent Includes" is a BBEdit thing. They're documented in the BBEdit manual in Appendix C: "Placeholders and Include Files.")
eo
On Mar 2, 2006, at 6:30 AM, csilver_junk@mac.com wrote:
Hello,
I've been a lurking member of this list for some time, but this is my first attempt at posting. I've been trying out TextMate in demo mode and plan to buy it because it's nearly perfect for the way I work, but I have a couple questions I'm hoping somebody could clear up for me.
I'm not a programmer, so please forgive me if my questions seem somewhat elementary. I do, however, use the Terminal quite often for shell commands, and I understand PHP well enough to write code for my own purposes. I prefer coding my web pages by hand, and I'm fluent in XHTML and CSS and competent in XSLT. I'm a bit anal about clean coding, usability, and accessibility (both for the end user and for me when writing my pages). For these reasons among others, I've been disappointed by virtually all of the website generation applications and/or scripts I've tried. It seems they require lots of convoluted configuration that just gets in my way. Besides, I'd rather just do it all myself with flat text files, using scripting just to generate the headers, footers, navigation, etc.
I'm not necessarily concerned with TextMate's ability to do the many super-complicated things it obviously can do, as I probably won't use most of it myself. However, I'm wondering if it has a feature similar to the Persistent Includes available in BBEdit. I have examined the manual and read about how to use snippets, templates, commands, and the like, and I understand how these could be used to make my life easier. The problem is that I haven't figured out if there's a way to re-parse an entire project or certain files within a project after I've made changes that will affect the output.
For instance, if I've used a script to output links to all the files contained in the directory (as a navigation menu of sorts) but later add more files to that same directory, I'd like to be able to re-generate the entire site so that those new files show up in the menu. Likewise, if I've generated prev/next links to other files in the same directory, I'd like to have them updated without having to manually type the new hyperlinks into each and every file of the site. I know I could use PHP or server-side includes or something similar (and I have written a simple php function to do just that), but I'd really like to generate static web pages because having dynamic pages online really isn't necessary for what I'm doing (also, I can upload the same files both to .Mac and to my virtual host, for example).
If nothing resembling Persistent Includes is available in TextMate, another viable option would be to auto-generate the output of an entire project but save it to a new directory on my system using the same hierarchy of the original project. That way, I can simply re-generate it whenever I need to. In fact, that would probably be a simpler solution than the Persistent Includes idea, but of course you all probably know much more about how to efficiently accomplish this than I do. Also, if anyone could point me in the direction of a good streamlined tutorial on how to use shell scripts in an environment such as TextMate, perhaps I can figure it out on my own. The TextMate manual is nice, but something more tutorial-like would help a lot.
Sorry for the long post - it actually started out longer with more details about my background and what I do, but I figured people may get annoyed, so I cut it. If I need to further clarify exactly what I need to accomplish, please ask, but I suspect most of you are quite familiar with BBEdit and know about how Persistent Includes work and how they differ from regular Includes.
Thanks,
Crystal
(By the way, "Persistent Includes" is a BBEdit thing. They're documented in the BBEdit manual in Appendix C: "Placeholders and Include Files.")
BBEdit stems from a period where you had to do everything from scratch (let's say, like under windoze). TextMate, on the other end, was developed with the clear intent of leveraging the UNIX text-processing infrastructure. Persistent includes have no reason to be in TM: we're all set with the bundling of a script like allan's (erb instead of php? php is... ugly!).
My .02€.
Domenico
On Mar 3, 2006, at 4:37 PM, Domenico Carbotta wrote:
(By the way, "Persistent Includes" is a BBEdit thing. They're documented in the BBEdit manual in Appendix C: "Placeholders and Include Files.")
BBEdit stems from a period where you had to do everything from scratch (let's say, like under windoze). TextMate, on the other end, was developed with the clear intent of leveraging the UNIX text-processing infrastructure. Persistent includes have no reason to be in TM: we're all set with the bundling of a script like allan's
Just my thought! ;)
(erb instead of php? php is... ugly!).
And "erb" is ... some Ruby thing, right? Not "The Educational Records Bureau" or "ERB Equipment Company -- An authorized John Deere Dealer." :)
My .02€.
Domenico
On 04 Mar 2006, at 02:43, Eric O'Brien wrote:
And "erb" is ... some Ruby thing, right? Not "The Educational Records Bureau" or "ERB Equipment Company -- An authorized John Deere Dealer." :)
;)
Yes ERb is an implementation of "Embedded Ruby"', it's a way to embed Ruby code in html (.rhtml) or text pages., like PHP. It is what Ruby on Rails uses to build the views.
-- FredB http://geekthang.com
On 3/3/06, Eric O'Brien ericob@possibilityengine.com wrote:
I just want the convenience, when I'm building it, of having repetitive parts that are common to many pages located in only ONE place.
While I don't know PHP, I bet I can figure out how to get include() to work for this simple case.
My personal rule is NEVER code it twice except for the minimal structure. Anything which might change goes in a separate file, all managed within a TM project. Files get included with PHP one-liners:
<?php @ require_once ("navbar.inc"); ?>
Shows up in every page, but to change navigation, I change it only in one place. It is essentially an Apache server side include using in php.
Here is another one. This defines a dropdown menu in a sidebar.
<div id="navcontainer"> <form method="post" action="" > <p> <select name="list1"> <option selected="selected" value="060315">Choose date</option> <option value="060315">Mar 2006</option> <option value="060206">Feb 2006</option> <option value="060109">Jan 2006</option> <option value="051205">Dec 2005</option> <option value="051102">Nov 2005</option> </select> <input type="hidden" name="_submit_check" value="1" /> <input type="submit" value="select" /> </p> </form> </div> <!-- navcontainer -->
The dynamic part is the list, of course, which makes up part of the file name.
Then this code, on the main page, loads one of the sub files into the page.
<?php if (array_key_exists('_submit_check', $_POST)) { /* ... do something with the form parameters ... */ $page=htmlentities($_POST['list1']); } ?> <?php @ require_once("board-$page.htmlf"); ?>
Not my original code, just adapted. Visit http://communityband.org/ to see it working. Look at the board archive or the program archive. After the concert on Sunday the third use of this gets emptied.
Lewy