GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   Programmers, how can I do this? (https://gfy.com/showthread.php?t=336553)

Groove 08-05-2004 09:35 AM

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.

Groove 08-05-2004 06:13 PM

Bump :glugglug

grumpy 08-05-2004 06:50 PM

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?

grumpy 08-05-2004 06:51 PM

im downloading the demo now to see what the options are.

grumpy 08-05-2004 06:56 PM

see what you mean

Intrigue 08-05-2004 10:07 PM

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.

Betray 08-05-2004 10:45 PM

^^^ 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 ;)

Varius 08-05-2004 10:48 PM

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?

Groove 08-06-2004 12:07 AM

Quote:

Originally posted by Varius
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?

All servers will be Unix of some description.

Varius 08-06-2004 12:11 AM

Quote:

Originally posted by Groove
All servers will be Unix of some description.
Ok, so you have few options:

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/*

Groove 08-06-2004 12:14 AM

Quote:

Originally posted by Betray
....but you would still have to run the script everytime you want to update it. unless you put the script on a timer ;)
Actually giving it a bit more thought... a CRON job may not be such a bad idea. It could be configured to run hourly, but only process files added since the last run.

iwantu 08-06-2004 12:19 AM

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";
}
}

Groove 08-06-2004 01:58 AM

Quote:

Originally posted by iwantu
Use this script

You owe me NOTHING!
:)


Many thanks! :)

Any chance of a brief description of what it does?
And installation/configuration requirements?

arachnO 08-06-2004 04:58 AM

Quote:

Originally posted by Groove
And installation/configuration requirements?
I think you don't need anything to use this script cause Perl is standart application for all *nixes.

grumpy 08-06-2004 06:56 AM

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 :-)

Groove 08-06-2004 08:23 AM

Quote:

Originally posted by grumpy
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 :-)

Many thanks for posting the question :)

But I DID ask Fog Creek support prior to posting on GFY and they replied:

Quote:

That tag is not merely cosmetic, it serves a purpose:

http://www.fogcreek.com/CityDesk/kb/...EveryFile.html

You would need to remove it from the published files
The response to your question (which I suspect was posted by a user) is a little more helpful than the one Fog Creek gave me. But it doesn't tell me how to "post-process your output HTML files before they're uploaded to the server". So I've posted a follow-up question.


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