From f3ea79a12a7bdf0d4efcd7eb706d25ae81b7fad9 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 17 May 2009 00:05:07 -0400 Subject: Added site path field to installer + fancy URL javascript auto-detection. --- index.php | 4 ++++ install.php | 31 ++++++++++++++++++++++++++----- js/install.js | 18 ++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) create mode 100644 js/install.js diff --git a/index.php b/index.php index e24bde917..cfef21189 100644 --- a/index.php +++ b/index.php @@ -63,6 +63,10 @@ function handleError($error) function main() { + // quick check for fancy URL auto-detection support in installer. + if ('/check-fancy' === $_SERVER['REDIRECT_URL']) { + die("Fancy URL support detection succeeded. We suggest you enable this to get fancy (pretty) URLs."); + } global $user, $action, $config; if (!_have_config()) { diff --git a/install.php b/install.php index 66e8e8712..32915200b 100644 --- a/install.php +++ b/install.php @@ -86,7 +86,8 @@ function checkExtension($name) function showForm() { -?> + $config_path = htmlentities(trim(dirname($_SERVER['REQUEST_URI']), '/')); + echo<< @@ -108,11 +109,21 @@ function showForm()

The name of your site

  • + + enable
    + disable
    +

    Enable fancy (pretty) URLs. Auto-detection failed, it depends on Javascript.

    +
  • Database hostname

  • +
  • + + +

    Site path, following the "/" after the domain name in the URL. Empty is fine. Field should be filled automatically.

    +
  • @@ -132,7 +143,8 @@ function showForm() -
    Page notice
    @@ -225,29 +239,34 @@ function handlePost() } updateStatus("Writing config file..."); $sqlUrl = "mysqli://$username:$password@$host/$database"; - $res = writeConf($sitename, $sqlUrl); + $res = writeConf($sitename, $sqlUrl, $fancy, $path); if (!$res) { updateStatus("Can't write config file.", true); showForm(); return; } updateStatus("Done!"); + if ($path) $path .= '/'; + updateStatus("You can visit your new Laconica site + +
    diff --git a/js/install.js b/js/install.js new file mode 100644 index 000000000..32a54111e --- /dev/null +++ b/js/install.js @@ -0,0 +1,18 @@ +$(document).ready(function(){ + $.ajax({url:'check-fancy', + type:'GET', + success:function(data, textStatus) { + $('#fancy-enable').attr('checked', true); + $('#fancy-disable').attr('checked', false); + $('#fancy-form_guide').text(data); + }, + error:function(XMLHttpRequest, textStatus, errorThrown) { + $('#fancy-enable').attr('checked', false); + $('#fancy-disable').attr('checked', true); + $('#fancy-enable').attr('disabled', true); + $('#fancy-disable').attr('disabled', true); + $('#fancy-form_guide').text("Fancy URL support detection failed, disabling this option. Make sure you renamed htaccess.sample to .htaccess."); + } + }); +}); + -- cgit v1.2.3