How to use css and javascript from other links

Jun 29, 2011 at 9:06 AM

Hi, How can I use the css and javascript from other server links?

Coordinator
Jun 29, 2011 at 12:50 PM

can u elaborate with an example, please? 

i don't really understand what you are asking.

Jun 29, 2011 at 1:49 PM

<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
  <UsingTask
      TaskName="CompressorTask"
      AssemblyFile="~\Bin\Yahoo.Yui.Compressor.dll" />
  <!-- The .NET 2.0 version of the task .. and yes .. that's Model.Net20 folder listed twice .. i know i know...
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="..\..\Projects\Yahoo.Yui.Compressor\Model.Net20\Model.Net20\bin\Debug\Yahoo.Yui.Compressor.NET20.dll" />
    -->

  <!-- Define the output locations. These can be set via the msbuild command line using
         /p:SourceLocation="$(ProjectDir)"
         /p:CssOutputFile=$(ProjectDir)../whatever...
         /p:JavaScriptOutputFile=$(ProjectDir)../whatever...
        
         If they are not supplied or are empty, then we the value whatever is supplied, below.
    -->
  <PropertyGroup>
    <CssOutputFile Condition=" '$(CssOutputFile)'=='' ">SylesSheetFinal.css</CssOutputFile>
    <JavaScriptOutputFile Condition=" '$(JavaScriptOutputFile)'=='' ">JavaScriptFinal.js</JavaScriptOutputFile>
  </PropertyGroup>

  <Target Name="MyTaskTarget">
    <!--
            ItemGroup\CssFiles or ItemGroup\JavaScriptFiles: add zero to many files you wish to include in this compression task.
                                                             Don't forget, you can use the wildcard (eg. *.css, *.js) if you feel up to it.
                                                             Finally, at least one item is required - either a css file or a js file.
                                                            
            CssFiles/JavaScriptFiles data format: Please do not touch this.
            DeleteCssFiles: [Optional] True | Yes | Yeah | Yep | True | FoSho | Fo Sho. Default is False. Anything else is False. (eg. blah = false, xxxx111 = false, etc)
            CssCompressionType: YuiStockCompression | MichaelAshsRegexEnhancements | HaveMyCakeAndEatIt or BestOfBothWorlds or Hybrid; Default is YuiStockCompression.
            ObfuscateJavaScript: [Optional] refer to DeleteCssFiles, above.
            PreserveAllSemicolons: [Optional] refer to DeleteCssFiles, above.
            DisableOptimizations: [Optional] refer to DeleteCssFiles, above.
            EncodingType: [Optional] ASCII, BigEndianUnicode, Unicode, UTF32, UTF7, UTF8, Default. Default is 'Default'.
            DeleteJavaScriptFiles: [Optional] refer to DeleteCssFiles, above.
            LineBreakPosition: [Optional] the position where a line feed is appened when the next semicolon is reached. Default is -1 (never add a line break).
                               0 (zero) means add a line break after every semicolon. (This might help with debugging troublesome files).         
            LoggingType: None | ALittleBit | HardcoreBringItOn;  Hardcore also lists javascript verbose warnings, if there are any (and there usually is :P ).
            ThreadCulture: [Optional] the culture you want the thread to run under. Default is 'en-gb'.
            IsEvalIgnored: [Optional] compress any functions that contain 'eval'. Default is False, which means a function that contains
                           'eval' will NOT be compressed. It's deemed risky to compress a function containing 'eval'. That said,
                           if the usages are deemed safe this check can be disabled by setting this value to True.
        -->

    <ItemGroup>
      <!-- Single files, listed in order of dependency -->
      <CssFiles Include="$(SourceLocation)Content\*.css"/>
      <!--<CssFiles Include="$(http://www.mydomain.com/mycss/css/cpe2_main_home.css)"/>-->

      <!--<JavaScriptFiles Include="$(http://www.mydomain.com/myjs/jq.js)"/>-->
      <JavaScriptFiles Include="$(SourceLocation)Scripts\*.js"/>
      <!-- All the files. They will be handled (I assume) in alphabetically. -->
      <!-- <CssFiles Include="$(SourceLocation)*.css" />
            <JavaScriptFiles Include="$(SourceLocation)*.js" />
            -->

    </ItemGroup>
   
    <Message Importance="high" Text="$(CssOutputFile)"/>
    <Message Importance="high" Text="$(JavaScriptOutputFile)"/>
   
    <CompressorTask
        CssFiles="@(CssFiles)"
        DeleteCssFiles="false"
        CssOutputFile="$(CssOutputFile)Content\mycss.css"
        CssCompressionType="YuiStockCompression"
        JavaScriptFiles="@(JavaScriptFiles)"
        ObfuscateJavaScript="True"
        PreserveAllSemicolons="False"
        DisableOptimizations="Nope"
        EncodingType="Default"
        DeleteJavaScriptFiles="false"
        LineBreakPosition="-1"
        JavaScriptOutputFile="$(JavaScriptOutputFile)Scripts\myjs.js"
        LoggingType="ALittleBit"
        ThreadCulture="en-au"
        IsEvalIgnored="false"
            />
  </Target>
</Project>

 

Im not success in it infect I can get the property window as well. Im using asp.net 3.5 and when i click on project property it will open property window like reference, build etc...

 

How can i success in it. Im not using infect mvc I am using simple web application can you help me out.

Coordinator
Jun 29, 2011 at 2:28 PM

Ah -  see what you're trying to do.

Currently, u can't get access to files that way. I've never tried it like that, but my gut instinct is that the current code won't work.

 

you need to supply a FILE LOCATION .

 

see how I do this:

 <!-- Define the output locations. These can be set via the msbuild command line using
         /p:SourceLocation="$(ProjectDir)"
         /p:CssOutputFile=$(ProjectDir)../whatever...
         /p:JavaScriptOutputFile=$(ProjectDir)../whatever...
         
         If they are not supplied or are empty, then we the value whatever is supplied, below.
    -->

<CssFiles Include="$(SourceLocation)Content\*.css"/>

This translate to something like C:\SomeFolder\Where\Your\Project\Exists\Content\*.css

I'm not a pro with MSBuild, but i've only played around with FILE LOCATION formats. eg. C:\blah...

Can you try that?

Jun 29, 2011 at 2:29 PM

Thanks Ok I'm using this and get back to you in 5 to 10 minutes. Thanks for waiting...

Jun 29, 2011 at 2:33 PM

Can you reorder this xml as you got the error. Because I can't get your idea.. :(

Jun 29, 2011 at 2:49 PM

should i do that?

 

 <!-- Define the output locations. These can be set via the msbuild command line using
         p:SourceLocation="$(ProjectDir)"
         /p:CssOutputFile=$(ProjectDir)../whatever...
         /p:JavaScriptOutputFile=$(ProjectDir)../whatever...
        
         If they are not supplied or are empty, then we the value whatever is supplied, below.
    -->
  /p:SourceLocation="$(C:\Inetpub\wwwroot\yui\)"
  /p:CssOutputFile=$(C:\Inetpub\wwwroot\yui\)
  /p:JavaScriptOutputFile=$(C:\Inetpub\wwwroot\yui\)

Coordinator
Jun 29, 2011 at 2:55 PM

try this..

<CssFiles Include="C:\Inetpub\wwwroot\yui\*.css" />

 

Jun 29, 2011 at 3:01 PM

Now is that ok

 

<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/MsBuild/2003">
  <UsingTask
      TaskName="CompressorTask"
      AssemblyFile="~\Bin\Yahoo.Yui.Compressor.dll" />
  <!-- The .NET 2.0 version of the task .. and yes .. that's Model.Net20 folder listed twice .. i know i know...
    <UsingTask
        TaskName="CompressorTask"
        AssemblyFile="..\..\Projects\Yahoo.Yui.Compressor\Model.Net20\Model.Net20\bin\Debug\Yahoo.Yui.Compressor.NET20.dll" />
    -->

  <!-- Define the output locations. These can be set via the msbuild command line using
         p:SourceLocation="$(ProjectDir)"
         /p:CssOutputFile=$(ProjectDir)../whatever...
         /p:JavaScriptOutputFile=$(ProjectDir)../whatever...
        
         If they are not supplied or are empty, then we the value whatever is supplied, below.
    -->
 
  <PropertyGroup>
    <CssOutputFile Condition=" 'C:\Inetpub\wwwroot\yui\Content\'=='' ">SylesSheetFinal.css</CssOutputFile>
    <JavaScriptOutputFile Condition=" 'C:\Inetpub\wwwroot\yui\Scripts\'=='' ">JavaScriptFinal.js</JavaScriptOutputFile>
  </PropertyGroup>

  <Target Name="MyTaskTarget">
    <!--
            ItemGroup\CssFiles or ItemGroup\JavaScriptFiles: add zero to many files you wish to include in this compression task.
                                                             Don't forget, you can use the wildcard (eg. *.css, *.js) if you feel up to it.
                                                             Finally, at least one item is required - either a css file or a js file.
                                                            
            CssFiles/JavaScriptFiles data format: Please do not touch this.
            DeleteCssFiles: [Optional] True | Yes | Yeah | Yep | True | FoSho | Fo Sho. Default is False. Anything else is False. (eg. blah = false, xxxx111 = false, etc)
            CssCompressionType: YuiStockCompression | MichaelAshsRegexEnhancements | HaveMyCakeAndEatIt or BestOfBothWorlds or Hybrid; Default is YuiStockCompression.
            ObfuscateJavaScript: [Optional] refer to DeleteCssFiles, above.
            PreserveAllSemicolons: [Optional] refer to DeleteCssFiles, above.
            DisableOptimizations: [Optional] refer to DeleteCssFiles, above.
            EncodingType: [Optional] ASCII, BigEndianUnicode, Unicode, UTF32, UTF7, UTF8, Default. Default is 'Default'.
            DeleteJavaScriptFiles: [Optional] refer to DeleteCssFiles, above.
            LineBreakPosition: [Optional] the position where a line feed is appened when the next semicolon is reached. Default is -1 (never add a line break).
                               0 (zero) means add a line break after every semicolon. (This might help with debugging troublesome files).         
            LoggingType: None | ALittleBit | HardcoreBringItOn;  Hardcore also lists javascript verbose warnings, if there are any (and there usually is :P ).
            ThreadCulture: [Optional] the culture you want the thread to run under. Default is 'en-gb'.
            IsEvalIgnored: [Optional] compress any functions that contain 'eval'. Default is False, which means a function that contains
                           'eval' will NOT be compressed. It's deemed risky to compress a function containing 'eval'. That said,
                           if the usages are deemed safe this check can be disabled by setting this value to True.
        -->

    <ItemGroup>
       Single files, listed in order of dependency
      <CssFiles Include="C:\Inetpub\wwwroot\yui\Content\*.css" />

      <JavaScriptFiles Include="C:\Inetpub\wwwroot\yui\Scripts\*.js"/>
     
       <!--All the files. They will be handled (I assume) in alphabetically.
       <CssFiles Include="$(SourceLocation)*.css" />
            <JavaScriptFiles Include="$(SourceLocation)*.js" />-->
           


    </ItemGroup>
   
    <Message Importance="high" Text="C:\Inetpub\wwwroot\yui\Content\*.css"/>
    <Message Importance="high" Text="C:\Inetpub\wwwroot\yui\Scripts\*.js"/>
   
    <CompressorTask
        CssFiles="C:\Inetpub\wwwroot\yui\Content\"
        DeleteCssFiles="false"
        CssOutputFile="C:\Inetpub\wwwroot\yui\Content\mycss.css"
        CssCompressionType="YuiStockCompression"
        JavaScriptFiles="C:\Inetpub\wwwroot\yui\Scripts\"
        ObfuscateJavaScript="True"
        PreserveAllSemicolons="False"
        DisableOptimizations="Nope"
        EncodingType="Default"
        DeleteJavaScriptFiles="false"
        LineBreakPosition="-1"
        JavaScriptOutputFile="C:\Inetpub\wwwroot\yui\Scripts\myjs.js"
        LoggingType="ALittleBit"
        ThreadCulture="en-au"
        IsEvalIgnored="false"
            />
  </Target>
</Project>

Jun 29, 2011 at 3:01 PM

Im not success still

Coordinator
Jun 29, 2011 at 3:21 PM

No dude, look carefully at this BLOCK of code...

<ItemGroup>
       Single files, listed in order of dependency 
      <CssFiles Include="C:\Inetpub\wwwroot\yui\Content\*.css" />

      <JavaScriptFiles Include="C:\Inetpub\wwwroot\yui\Scripts\*.js"/>
      
       <!--All the files. They will be handled (I assume) in alphabetically. 
       <CssFiles Include="$(SourceLocation)*.css" />
            <JavaScriptFiles Include="$(SourceLocation)*.js" />-->
            
    </ItemGroup>

Notice how u have set the CSS and JS to be the exact path .. which is good.

 

THEN u try adding more files, which are wrong..

 

this is what it should be like...

<ItemGroup>
      <CssFiles Include="C:\Inetpub\wwwroot\yui\Content\*.css" />
      <JavaScriptFiles Include="C:\Inetpub\wwwroot\yui\Scripts\*.js"/>            
</ItemGroup>