modolabs / Kurogo-Mobile-Web

Kurogo is a PHP framework for delivering high quality, data driven customizable content to a wide range of mobile devices. Its strengths lie in the customizable system that allows you to adapt content from a variety of sources and easily present that to mobile devices from feature phones, to early generation smart phones, to modern devices and tablets
http://kurogo.org
GNU Lesser General Public License v2.1
198 stars 99 forks source link

If device debugging is on, css minify device dection call fails in certain cases #25

Closed andrewguertin closed 13 years ago

andrewguertin commented 13 years ago

On the UVM home page (http://m.uvm.edu/home/), if device debugging (Kurogo::getSiteVar('DEVICE_DEBUG')) is on, then when viewed with a tablet, certain background images do not display.

Specifically, the arrow images (page-next.png, page-dot.png, page-prev.png) have incorrect URLs, for example http://m.uvm.edu/device/unknown-unknown-0/common/images/page-next.png instead of http://m.uvm.edu/device/tablet/common/images/page-next.png or http://m.uvm.edu/common/images/page-next.png

We believe we have tracked this as far as the function minifyPostProcess() in lib/minify.php:

function minifyPostProcess($content, $type) {
  if ($type === Minify::TYPE_CSS) {
    $urlPrefix = URL_PREFIX;

    if (Kurogo::getSiteVar('DEVICE_DEBUG') && URL_PREFIX == URL_BASE) {
      // if device debugging is on, always append device classification
      $urlPrefix .= 'device/'.Kurogo::deviceClassifier()->getDevice().'/';
    }

    $content = "/* Adding url prefix '".$urlPrefix."' */\n\n".
      preg_replace(';url\("?\'?/([^"\'\)]+)"?\'?\);', 'url("'.$urlPrefix.'\1")', $content);
  }

  return $content;
}

In this one specific case, Kurogo::deviceClassifier()->getDevice() seems to return "unknown-unknown-0" instead of the correct values. The problem does not occur with other background images, thus in other cases this call must work properly.

Note that because this relies on device detection, using the device forcing does NOT show the problem (i.e. http://m.uvm.edu/device/tablet/home/ looks correct). However, spoofing a tablet user agent will allow it to be seen on a computer.

We are using version 1.2, and we have tested that this problem also occurs using the Universitas site.

arkonan commented 13 years ago

Should be fixed in master now. Let us know if it still isn't working for you.

eebs commented 13 years ago

Cherry-picked commit ada86ad136e387d44f98 and that fixed the issue. Thank you, please close this issue.