尽管有过滤器,但是没有修复相对URL?

时间:2011-10-20 20:49:01

标签: css filter relative-path combres

更新:以下是我认为存在问题的CSS示例:

.ui-widget-content { border: 1px solid #aaaaaa/*{borderColorContent}*/; background: #ffffff/*{bgColorContent}*/ url(images/ui-bg_flat_75_ffffff_40x100.png)/*{bgImgUrlContent}*/ 50%/*{bgContentXPos}*/ 50%/*{bgContentYPos}*/ repeat-x/*{bgContentRepeat}*/; color: #222222/*{fcContent}*/; }

更新 - 在问题搜索中创建了workitem问题跟踪器。

更新:我查看了日志,发现了发生的事情 -

2011-10-24 16:32:20,490 [15] WARN  Combres.Filters.FixUrlsInCssFilter - Cannot fix url url(images/ui-icons_454545_256x240.png)
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length, Boolean fAlwaysCopy)
   at System.String.Substring(Int32 startIndex, Int32 length)
   at Combres.Filters.FixUrlsInCssFilter.FixUrl(Resource resource, Match match)

那么,我可以获取源代码并查看它,还是我需要将它放在combres问题跟踪器上?

我正在使用过滤器 -

 <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" />

应该修复提到here的相对网址问题。但是网址(css背景图片)仍在使用错误的路径并执行类似

的操作

http://somedomain.com/combres.axd/pics/pic.png

而不是使用

http://somedomain.com/pics/pic.png

我也尝试使用 -

明确申请
<filter type="Combres.Filters.FixUrlsInCssFilter, Combres" acceptedResourceSets="myCss"  />

任何人都可以提出我的建议吗?我发现了一些similar,但它的解决方案对我不起作用。

更新:这是我的combres.xml以防万一 -

<?xml version="1.0" encoding="utf-8" ?>
<!--
  This file contains basic settings needed for most web apps.
  For full Combres settings (with explanation), refer to the sample definition file: combres_full_with_annotation.xml
  Also, refer to Combres' documentation: http://combres.codeplex.com/documentation  
-->
<combres xmlns='urn:combres'>
  <filters>
    <filter type="Combres.Filters.FixUrlsInCssFilter, Combres" acceptedResourceSets="LogCreateCss"  />
    <filter type="Combres.Filters.DotLessCssFilter, Combres"  acceptedResourceSets="LogCreateCss"  />
  </filters>
  <cssMinifiers>
    <minifier name="yui" type="Combres.Minifiers.YuiCssMinifier, Combres">
      <param name="CssCompressionType" type="string" value="StockYuiCompressor" />
      <param name="ColumnWidth" type="int" value="-1" />
    </minifier>
  </cssMinifiers>
  <jsMinifiers>
    <minifier name="msajax" type="Combres.Minifiers.MSAjaxJSMinifier, Combres" binderType="Combres.Binders.SimpleObjectBinder, Combres">
      <param name="CollapseToLiteral" type="bool" value="true" />
      <param name="EvalsAreSafe" type="bool" value="true" />
      <param name="MacSafariQuirks" type="bool" value="true" />
      <param name="CatchAsLocal" type="bool" value="true" />
      <param name="LocalRenaming" type="string" value="CrunchAll" />
      <param name="OutputMode" type="string" value="SingleLine" />
      <param name="RemoveUnneededCode" type="bool" value="true" />
      <param name="StripDebugStatements" type="bool" value="true" />
    </minifier>
    <minifier name="yui" type="Combres.Minifiers.YuiJSMinifier, Combres">
      <param name="IsVerboseLogging" type="bool" value="false" />
      <param name="IsObfuscateJavascript" type="bool" value="true" />
      <param name="PreserveAllSemicolons" type="bool" value="false" />
      <param name="DisableOptimizations" type="bool" value="true" />
      <param name="LineBreakPosition" type="int" value="-1" />
    </minifier>
  </jsMinifiers>
  <resourceSets url="~/combres.axd" defaultDuration="30"
                                defaultVersion="auto"
                                defaultDebugEnabled="false"
                                defaultJSMinifierRef="msajax"
                                defaultCssMinifierRef="yui">
    <resourceSet name="siteCss" type="css" minifierRef="yui">
      <resource path="\Content\StyleSheets\reset.css" />
      <resource path="\Content\StyleSheets\960.css" />
      <resource path="\Content\StyleSheets\Site960.css" />
      <resource path="\Content\StyleSheets\Site.css" />
    </resourceSet>
    <resourceSet name="siteJs" type="js" minifierRef="msajax">
      <resource path="\Scripts\jquery-1.5.1.min.js" />
      <resource path="\Content\Scripts\blockUI.js"  />
    </resourceSet>
    <resourceSet name="overviewCss" type="css" minifierRef="yui">
      <resource path="\Content\Plugins\fancybox\css\jquery.fancybox-1.3.4.css" />
      <resource path="\Content\StyleSheets\overview_kam.css" />
    </resourceSet>
    <resourceSet name="overviewJs" type="js" minifierRef="msajax">
      <resource path="\Content\Plugins\fancybox\scripts\jquery.fancybox-1.3.4.pack.js" />
    </resourceSet>
    <resourceSet name="LogCreateCss" type="css" minifierRef="yui">
      <resource path="\Content\Plugins\fancybox\css\jquery.fancybox-1.3.4.css" />
    </resourceSet>
    <resourceSet name="activityLogCloseCreateJs" type="js" minifierRef="msajax">
      <resource path="\Content\Plugins\fancybox\scripts\jquery.fancybox-1.3.4.pack.js" />
      <resource path="\Content\Plugins\fancybox\scripts\jquery.fancybox-1.3.4.js" />
    </resourceSet>
    <resourceSet name="LogCreateCss" type="css" minifierRef="yui">
      <resource path="\Content\StyleSheets\Site.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.all.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery-ui.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.accordion.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.autocomplete.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.button.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.core.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.datepicker.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.dialog.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.menu.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.progressbar.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.resizable.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.selectable.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.slider.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.spinner.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.tabs.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.theme.css" />
      <resource path="\Content\Plugins\jquerySpinner\themes\base\jquery.ui.tooltip.css" />
      <resource path="\Content\Plugins\jquerySpinner\demos\demos.css" />
    </resourceSet>
    <resourceSet name="LogCreateJs" type="js" minifierRef="msajax"  >
      <resource path="\Content\Plugins\jquerySpinner\jquery-1.4.3.js" />
      <resource path="\Content\Scripts\ActivityLog\Create.js" />
      <resource path="\Content\Plugins\fancybox\scripts\jquery.fancybox-1.3.4.pack.js" />
      <resource path="\Content\Plugins\jquerySpinner\external\jquery.mousewheel-3.0.4.js" />
      <resource path="\Content\Plugins\jquerySpinner\external\glob.js" />
      <resource path="\Content\Plugins\jquerySpinner\external\glob.de-DE.js" />
      <resource path="\Content\Plugins\jquerySpinner\external\glob.ja-JP.js" />
      <resource path="\Content\Plugins\jquerySpinner\ui\jquery.ui.core.js" />
      <resource path="\Content\Plugins\jquerySpinner\ui\jquery.ui.widget.js" />
      <resource path="\Content\Plugins\jquerySpinner\ui\jquery.ui.button.js" />
      <resource path="\Content\Plugins\jquerySpinner\ui\jquery.ui.spinner.js" />

    </resourceSet>
  </resourceSets>
</combres>

1 个答案:

答案 0 :(得分:2)

我认为你的CSS的图像部分是畸形的;试试这个:

url('images/ui-bg_flat_75_ffffff_40x100.png') /*{bgImgUrlContent}*/

请注意添加单引号以及结束“)”和注释块

之间的空格

根据经验,我可以建议使用应用程序根相对语法来保持清洁,例如,我会改变你所拥有的:

url('~/images/ui-bg_flat_75_ffffff_40x100.png') /*{bgImgUrlContent}*/

<强>更新

另一种选择是编写自己的ISingleContentFilter实现,它更能容忍css文件中出现的语法。您可以看一下combres FixUrlsInCssFilter,以获得良好的起点。

<强>更新

如果您已经创建了自己的过滤器改进版本,只需将其编译为Web项目的一部分,并在combres.xml中引用它:

<filters>
      <filter type="YourProject.MyBetterFilter, YourProject" />
</filters>

没有必要完全重新编译(并保留)自定义版本的Combres以这种方式扩展它。