![]() |
Programmers, how can I do this?
I want to use CityDesk, a desktop content management program:
http://www.fogcreek.com/CityDesk/ to manage some static HTML freesites. However CityDesk adds a metatag to all pages which I want to get rid of. I could publish the pages locally, do a search and replace, then upload to the servers. But it would be MUCH more efficient to do an automated search and replace on the servers. Would it be difficult to write a server-side script that deletes the metatag from all pages, bearing in mind that these pages will published across multiple domains and multiple virtual hosts? Also please note that I'd prefer to run the script on demand rather than as a CRON job. If this is something that you could write for me, please describe your proposed solution and provide a ballpark cost. |
Bump :glugglug
|
download the stuff...multifile replace and upload the stuff.
But arent those pages generated on the fly...meaning they would have to modify there script? |
im downloading the demo now to see what the options are.
|
see what you mean
|
Your best bet's probably a perl script you can run via cgi, to go through the files, and use a regex on each one. If you want me to do it, you'll have to get ahold of our sales guy:
AIM: Avanteguard MSN: matt [ at ] imadigan.com Email: matt [ at ] imadigan.com ICQ: 314942262 and he'll take care of you. |
^^^ exactly what he said, this would be your best bet.. but you would still have to run the script everytime you want to update it. unless you put the script on a timer ;)
|
If you're in UNIX, you can just have a script using "rep" on files you upload.
If Windows, I dunno maybe a .bat file? |
Quote:
|
Quote:
1 - crontab script, but you said you wanted to avoid that 2 - get your server to execute a script whenever 'x' is uploaded. Probably the most complicated as you have to hack some sources and recompile stuff. 3 - have script you run manually. Just make a super easy shell script that will execute rep. ie. #!/bin/sh rep -R 'metag tag line' '' /dir/* |
Quote:
|
Use this script
You owe me NOTHING! :) sub replace; $recursive = 0; sub Printmenu { print "Usage is: recureplace [option] 'find text' 'replace text' file1 file2 ... \n\n"; print " Replace the specified text in the specified files.\n\n"; print " options are:\n"; print " -e file_extension to replace word only in files matching the\n"; print " extension\n"; print " -R Recursive Perform recursively the replacement on all the\n"; print " files of all directories\n"; exit; } while ($ARGV[0] =~ /^-/) { if ($ARGV[0] eq "-R") { $recursive = 1;} elsif ($ARGV[0] eq "-e") { shift; $extension = $ARGV[0];} shift; } if (($ARGV[0] eq "") || ($ARGV[1] eq "")) { &Printmenu;} $find_txt = $ARGV[0]; shift; $replace_txt = $ARGV[0]; shift; &find('.'); [zeus@baileys (Aug 06 - 3:17am) - /home/zeus] ls -la /usr/local/bin/rep -rwxr-xr-x 1 root wheel 2386 Jul 1 2002 /usr/local/bin/rep [zeus@baileys (Aug 06 - 3:17am) - /home/zeus] more /usr/local/bin/rep #!/usr/bin/perl sub replace; $recursive = 0; sub Printmenu { print "Usage is: recureplace [option] 'find text' 'replace text' file1 file2 ... \n\n"; print " Replace the specified text in the specified files.\n\n"; print " options are:\n"; print " -e file_extension to replace word only in files matching the\n"; print " extension\n"; print " -R Recursive Perform recursively the replacement on all the\n"; print " files of all directories\n"; exit; } while ($ARGV[0] =~ /^-/) { if ($ARGV[0] eq "-R") { $recursive = 1;} elsif ($ARGV[0] eq "-e") { shift; $extension = $ARGV[0];} shift; } if (($ARGV[0] eq "") || ($ARGV[1] eq "")) { &Printmenu;} $find_txt = $ARGV[0]; shift; $replace_txt = $ARGV[0]; shift; &find('.'); sub find { local($dir,$nlink) = @_; local($dev,$ino,$mode,$subcount); ($dev,$ino,$mode,$nlink) = stat ('.') unless $nlink; opendir(DIR,'.')|| die "Can't open $dir"; local(@filenames)= readdir(DIR); closedir(DIR); if (!($recursive)) { @filenames = @ARGV; } $subcount = $nlink - 1; for (@filenames) { next if $_ eq '.'; next if $_ eq '..'; $name= $_; if (!(-d $name)){ if ($extension ne '') { next if (!(m/.*\.$extension$/i)) } replace($name); } next if $subcount hahahaha0; ($dev,$ino,$mode,$nlink) = lstat($_); next unless -d _; if ($recursive) { print "\nDirectory: $dir/$name\n"; chdir $_ || die "Can't cd to $name"; &find($name,$nlink); chdir '..'; --$subcount; } } } sub replace { local ($filename)= @_; if ((-r $filename) && (-w $filename) && (-s $filename)) { $size = (-s $filename); print "Replacing $find_txt by $replace_txt in $filename ($size)\n"; open(FILE,"<$filename"); read(FILE, $file_text, $size, 0); close(FILE); $file_text =~ s/$find_txt/$replace_txt/g; open(FILE,">$filename") || die "Could not create $filename\n"; print FILE $file_text; close(FILE); } else { print "I have no right to modify $filename"; } } |
Quote:
Any chance of a brief description of what it does? And installation/configuration requirements? |
Quote:
|
http://discuss.fogcreek.com/citydesk...68&ixReplies=1
I just asked them... there is your answer. So next time i think ist easier when you ask their support :-) |
Quote:
But I DID ask Fog Creek support prior to posting on GFY and they replied: Quote:
|
All times are GMT -7. The time now is 09:31 AM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123