App-proxyforurl

 view release on metacpan or  search on metacpan

script/proxyforurl  view on Meta::CPAN

    $c->req->url->base(Mojo::URL->new($base));
  };
}

app->renderer->paths([$ENV{PROXYFORURL_TEMPLATES} || 'templates']);
app->static->paths([$ENV{PROXYFORURL_PUBLIC}      || 'public']);
app->config(brand_name => $ENV{PROXYFORURL_BRAND_NAME} || 'ProxyForURL');
app->config(brand_url  => $ENV{PROXYFORURL_BRAND_URL}  || '/');
app->start;

sub exception_to_text ($err) {
  $err =~ s!\sat\s\S+.*?line.*!!s;
  return $err;
}

__DATA__
@@ layouts/pac.html.ep
<!DOCTYPE html>
<html>
  <head>
    %= include 'partial/pac/head'
  </head>
  <body>
    <nav>
      %= include 'partial/pac/nav'
    </nav>
    <div class="container">
      <article>
        <header>
          <h1>Online proxy PAC file tester</h1>
          <p>Enter the content of your PAC file and test it against a URL.</p>
        </header>
        %= content
        <footer>
          <a href="https://github.com/jhthorsen/app-proxyforurl">This program</a> is free software,
          you can redistribute it and/or modify it under the terms of the
          <a href="https://spdx.org/licenses/Artistic-2.0.html">Artistic License version 2.0</a>.
        </footer>
      </article>
    </div>
    %= javascript begin
      const switcher = document.getElementById('theme_switcher');
      const setTheme = (e) => {
        const prefers = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
        const other = prefers === 'dark' ? 'light' : 'dark';
        document.documentElement.setAttribute('data-theme', e.target.checked ? other : prefers);
      };
      switcher.addEventListener('click', setTheme);
      setTheme({target: switcher});
    % end
  </body>
</html>
@@ partial/pac/head.html.ep
<title>Online proxy PAC file tester</title>
%= stylesheet 'https://unpkg.com/@picocss/pico@1.*/css/pico.min.css'
%= stylesheet begin
  body {
    margin-top: 5rem;
  }
  nav {
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: saturate(150%) blur(18px);
    border-bottom: 1px solid var(--muted-border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1;
  }
  footer {
    font-size: 14px;
  }
  textarea {
    height: 18em;
  }
  label[data-tooltip] {
    border: 0;
  }
  #pac_log tbody tr:first-child td {
    color: var(--code-value-color);
    font-weight: bold;
    border-bottom: 4px double var(--code-value-color);
    vertical-align: top;
  }
  #pac_log tbody tr:first-child:last-child td {
    height: 8rem;
  }
% end
@@ partial/pac/nav.html.ep
<ul>
  <li>&nbsp;</li>
  <li><a href="<%= config 'brand_url' %>"><%= config 'brand_name'  %></a></li>
</ul>
<ul>
  <li>
    <label data-tooltip="Switch dark/light mode" data-placement="left">
      <input type="checkbox" id="theme_switcher" role="switch" aria-label="Switch dark/light mode">
    </label>
  </li>
  <li>&nbsp;</li>
</ul>
@@ index.html.ep
%= form_for '/', method => 'post', id => 'proxy_for_url', begin
  <label for="pac_rules">
    <span>PAC file</span>
    <textarea id="pac_rules" name="rules"></textarea>
  </label>
  <div class="grid">
    <label for="pac_url">
      <span>URL</span>
      %= text_field 'url', 'http://example.com', id => 'pac_url', placeholder => 'http://example.com'
    </label>
    <label for="pac_host">
      <span>Host</span>
      %= text_field 'host', '', id => 'pac_host', placeholder => 'From URL'
    </label>
    <label for="pac_my_ip_address">
      <span>Your IP address</span>
      %= text_field 'my_ip_address', 'http://example.com', id => 'pac_my_ip_address', placeholder => 'http://example.com'
    </label>
  </div>



( run in 0.556 second using v1.01-cache-2.11-cpan-f56aa216473 )