Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Made hostname dynamic via $hostname variable which checks if ENV{APP_…

…DUCKPAN_SERVER_HOSTNAME} otherwise it defaults to 'duckduckgo.com'
  • Loading branch information...
commit 4a6d74fd2f4780365d47500242239d170ae01f48 1 parent c12e25b
@moollaza moollaza authored
Showing with 9 additions and 7 deletions.
  1. +9 −7 lib/App/DuckPAN/Cmd/Server.pm
View
16 lib/App/DuckPAN/Cmd/Server.pm
@@ -28,29 +28,31 @@ sub run {
print "\n\nTrying to fetch current versions of the HTML from http://duckduckgo.com/\n\n";
+ my $hostname = defined $ENV{APP_DUCKPAN_SERVER_HOSTNAME} ? $ENV{APP_DUCKPAN_SERVER_HOSTNAME} : 'duckduckgo.com';
+
my $fetch_page_root;
- if ($fetch_page_root = get('http://duckduckgo.com/')) {
+ if ($fetch_page_root = get('http://'.$hostname.'/')) {
io(file($self->app->cfg->cache_path,'page_root.html'))->print($self->change_html($fetch_page_root));
} else {
print "\nRoot fetching failed, will just use cached version..."
}
my $fetch_page_spice;
- if ($fetch_page_spice = get('http://duckduckgo.com/?q=duckduckhack-template-for-spice')) {
+ if ($fetch_page_spice = get('http://'.$hostname.'/?q=duckduckhack-template-for-spice')) {
io(file($self->app->cfg->cache_path,'page_spice.html'))->print($self->change_html($fetch_page_spice));
} else {
print "\nSpice-Template fetching failed, will just use cached version..."
}
my $fetch_page_css;
- if ($fetch_page_css = get('http://duckduckgo.com/style.css')) {
+ if ($fetch_page_css = get('http://'.$hostname.'/style.css')) {
io(file($self->app->cfg->cache_path,'page.css'))->print($self->change_css($fetch_page_css));
} else {
print "\nCSS fetching failed, will just use cached version..."
}
my $fetch_page_js;
- if ($fetch_page_js = get('http://duckduckgo.com/duckduck.js')) {
+ if ($fetch_page_js = get('http://'.$hostname.'/duckduck.js')) {
io(file($self->app->cfg->cache_path,'page.js'))->print($self->change_js($fetch_page_js));
} else {
print "\nJavaScript fetching failed, will just use cached version..."
@@ -114,7 +116,7 @@ sub change_html {
if ($_->attr('type') && $_->attr('type') eq 'text/css') {
$_->attr('href','/?duckduckhack_css=1');
} elsif (substr($_->attr('href'),0,1) eq '/') {
- $_->attr('href','http://duckduckgo.com'.$_->attr('href'));
+ $_->attr('href','http://'.$hostname.''.$_->attr('href'));
}
}
@@ -127,7 +129,7 @@ sub change_html {
if ($src =~ m/^\/d\d{3}\.js/) {
$_->attr('src','/?duckduckhack_js=1');
} elsif (substr($src,0,1) eq '/') {
- $_->attr('src','http://duckduckgo.com'.$_->attr('src'));
+ $_->attr('src','http://'.$hostname.''.$_->attr('src'));
}
}
}
@@ -138,7 +140,7 @@ sub change_html {
for (@img) {
if ($_->attr('src')) {
- $_->attr('src','http://duckduckgo.com'.$_->attr('src'));
+ $_->attr('src','http://'.$hostname.''.$_->attr('src'));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.