Does anyone have an idea on how I can quickly add some HTML code to every page generated by iFamily?
I would like to know statistics about my website; things like the most popular pages, sources, time spent on the site, etc.
There are plenty of tools available to track this however they all require a small piece of HTML on each page.
iFamily doesn't appear to allow you to customize the default HTML page (does it?), so I wonder if anyone knows of a tool that would go through every page and add the same piece of code before I upload the pages. At the moment i have over 500 pages and I am sure that will grow, so doing it manually is not an option
thanks
adding code to each HTML page
- Warwick Wilson
- Site Admin
- Posts: 495
- Joined: Sat Nov 15, 2008 12:36 am
- Contact:
Using a "find and replace in files" from a text editor, you will be able to search for.
</body>
(or </html>)
and replace it with
[your code]
</body>
in all files contained in the /HTMLFiles/ directory. This becomes trickier if you want an different identifier in each file.
Is this applicable to your case and does anyone know a batching text editor. (to avoid using grep, which may also work).
</body>
(or </html>)
and replace it with
[your code]
</body>
in all files contained in the /HTMLFiles/ directory. This becomes trickier if you want an different identifier in each file.
Is this applicable to your case and does anyone know a batching text editor. (to avoid using grep, which may also work).
Yes, but there lies my problem -- I can't source a find and replace tool which works on multiple files. I am all googled out!Warwick Wilson wrote:Using a "find and replace in files" from a text editor, you will be able to search for.
No, it's the same small piece of code.Warwick Wilson wrote:This becomes trickier if you want an different identifier in each file.
I had a look behind the scenes in the package contents of iFamily to see if there was a template HTML file, but alas nothing
Thanks
David
http://jamiesontree.uk
http://jamiesontree.uk
I think I have cracked it.
grep only finds as far as I remember, but then sed popped into my head, after Warwick mentioned grep
So I think this should do the job
The annoying thing about sed is that you need to output the result to a tempfile and then rename it back
If anyone has a smarter way, then it would be much appreciated
grep only finds as far as I remember, but then sed popped into my head, after Warwick mentioned grep
So I think this should do the job
Code: Select all
for i in $(find . -type f); do sed 's|</body>|MYCODEHERE</body>|g' $i > $i-tmp; mv $i $i-backup; mv $i-tmp $i; done
If anyone has a smarter way, then it would be much appreciated
David
http://jamiesontree.uk
http://jamiesontree.uk
- Warwick Wilson
- Site Admin
- Posts: 495
- Joined: Sat Nov 15, 2008 12:36 am
- Contact:
correct, grep cannot do a replace. This (sed) works:
Navigate to the HTMLFiles_01 directory in your shell terminal then type:
sed -i .bak 's/<\/body>/<bold>hello kitty<\/bold><\/body>/g' *
[remember to use the escape character whenever you have a slash.]
* refers to all files in the current directory
"-i .bak" changes it in place in the file, and creates a backup with a .bak extension.
in quote syntax = 's/findText/ReplaceText/g'
g refers to all occurences, not sure what the s is for.
... Surely someone has coded this into a text editor GUI somewhere.
Navigate to the HTMLFiles_01 directory in your shell terminal then type:
sed -i .bak 's/<\/body>/<bold>hello kitty<\/bold><\/body>/g' *
[remember to use the escape character whenever you have a slash.]
* refers to all files in the current directory
"-i .bak" changes it in place in the file, and creates a backup with a .bak extension.
in quote syntax = 's/findText/ReplaceText/g'
g refers to all occurences, not sure what the s is for.
... Surely someone has coded this into a text editor GUI somewhere.
Last edited by Warwick Wilson on Thu May 14, 2009 8:01 pm, edited 3 times in total.
I found a GUI -- yipee
Smultron is my new friend
It's open source too, so no cash had to change hands
I'm up and running and tracking activity
Smultron is my new friend
It's open source too, so no cash had to change hands
I'm up and running and tracking activity
David
http://jamiesontree.uk
http://jamiesontree.uk
- Warwick Wilson
- Site Admin
- Posts: 495
- Joined: Sat Nov 15, 2008 12:36 am
- Contact:
Oh.. this from the Enhancements request fora, JEdit may also be a good free solution here:
http://ifamilyforleopard.com/forums/viewtopic.php?t=403
http://ifamilyforleopard.com/forums/viewtopic.php?t=403
Text Wrangler and its commercial bigger brother, BBEdit, are also great programs for doing search and replace within files and across file groups with or without using regular expressions.daj wrote:I found a GUI -- yipee
Smultron is my new friend
It's open source too, so no cash had to change hands
I'm up and running and tracking activity
Al