Changeset 233

Show
Ignore:
Timestamp:
11/14/08 06:00:34 (2 months ago)
Author:
louis.dejardin
Message:

Changes for iron python branch complete

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/scripting/src/Samples/AspNetMvc/IronPythonViews/Controllers/HomeController.cs

    r231 r233  
    11using System; 
     2using System.Collections.Generic; 
    23using System.Data; 
    34using System.Configuration; 
     
    1213using System.Xml.Linq; 
    1314using IronPythonViews.Models; 
     15using System.Web.Mvc.Html; 
    1416 
    1517namespace IronPythonViews.Controllers 
     
    2224            ViewData["products"] = repos.GetProducts(); 
    2325            ViewData["foo"] = "bar"; 
    24             ViewData["quux"] = 3+4+5; 
     26            ViewData["quux"] = 3 + 4 + 5; 
     27            return View(); 
     28        } 
     29 
     30        public ActionResult About() 
     31        { 
     32            return View(); 
     33        } 
     34 
     35        public ActionResult AddingAtPlaceholders() 
     36        { 
     37            return View(); 
     38        } 
     39 
     40        public ActionResult StyleGuide() 
     41        { 
     42            return View(); 
     43        } 
     44 
     45        public ActionResult Boxes() 
     46        { 
     47            return View(); 
     48        } 
     49 
     50        public ActionResult PagingAndRepeater(int? id) 
     51        { 
     52            var pageNumber = id ?? 1; 
     53            var pageSize = 10; 
     54 
     55            var repos = new BirdRepository(); 
     56            var allBirds = repos.GetBirds(); 
     57            var showBirds = allBirds.Skip((pageNumber - 1) * pageSize).Take(pageSize); 
     58            var birdCount = allBirds.Count(); 
     59             
     60            ViewData["birds"] = new Page<Bird> 
     61            { 
     62                Items = showBirds, 
     63                ItemCount = birdCount, 
     64 
     65                CurrentPage = pageNumber, 
     66                PageCount = (birdCount + pageSize - 1) / pageSize, 
     67 
     68                FirstItemIndex = (pageNumber - 1) * pageSize 
     69            }; 
    2570            return View(); 
    2671        } 
    2772    } 
     73 
     74    public class Page<TItem> 
     75    { 
     76        public IEnumerable<TItem> Items { get; set; } 
     77        public int ItemCount { get; set; } 
     78 
     79        public int CurrentPage { get; set; } 
     80        public int PageCount { get; set; } 
     81 
     82        public int FirstItemIndex { get; set; } 
     83 
     84        public bool HasPreviousPage { get { return CurrentPage > 1; } } 
     85        public bool HasNextPage { get { return CurrentPage < PageCount; } } 
     86 
     87    } 
    2888} 
  • branches/scripting/src/Samples/AspNetMvc/IronPythonViews/IronPythonViews.csproj

    r231 r233  
    103103  <ItemGroup> 
    104104    <Content Include="App_Data\Products.xml" /> 
     105    <Content Include="Content\andreas08\andreas08.css" /> 
     106    <Content Include="Content\andreas08\index.html" /> 
     107    <Content Include="Content\extra.css" /> 
     108    <Content Include="Content\pagination.css" /> 
    105109    <Content Include="Default.aspx" /> 
    106110    <Content Include="Global.asax" /> 
     111    <EmbeddedResource Include="Models\BirdList.txt" /> 
    107112    <Content Include="Web.config" /> 
    108113  </ItemGroup> 
     
    113118    </Compile> 
    114119    <Compile Include="Global.cs" /> 
     120    <Compile Include="Models\Bird.cs" /> 
     121    <Compile Include="Models\BirdRepository.cs" /> 
    115122    <Compile Include="Models\Product.cs" /> 
    116123    <Compile Include="Models\ProductRepository.cs" /> 
     
    118125  </ItemGroup> 
    119126  <ItemGroup> 
     127    <Content Include="Views\Home\AddingAtPlaceholders.spark" /> 
     128    <None Include="Views\Home\About.spark" /> 
     129    <None Include="Views\Home\Boxes.spark" /> 
    120130    <None Include="Views\Home\Index.spark" /> 
     131    <None Include="Views\Home\PagingAndRepeater.spark" /> 
     132    <None Include="Views\Home\Styleguide.spark" /> 
    121133    <None Include="Views\Layouts\Application.spark" /> 
     134    <None Include="Views\Shared\_AllDemoPages.spark" /> 
     135    <None Include="Views\Shared\_Box.spark" /> 
     136    <None Include="Views\Shared\_Comment.spark" /> 
     137    <None Include="Views\Shared\_DefaultRightrail.spark" /> 
     138    <None Include="Views\Shared\_Jabberwocky.spark" /> 
     139    <None Include="Views\Shared\_Pagination.spark" /> 
     140    <None Include="Views\Shared\_RoundBox.spark" /> 
     141    <None Include="Views\Shared\_Rows.spark" /> 
     142    <None Include="Views\Shared\_SmallBox.spark" /> 
    122143  </ItemGroup> 
    123144  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> 
  • branches/scripting/src/Samples/AspNetMvc/IronPythonViews/Views/Home/Index.spark

    r231 r233  
    11 
    2 #import clr 
    3  
    4 ${Html.ActionLink("one","two")} 
    5 ${Html.ActionLink("one")} 
    6  
     2<h2>Demonstration of advanced partial techniques</h2> 
     3<p>Includes the following</p> 
    74<ul> 
    8   <li each="x in dir(clr)">${x}</li> 
    9 </ul> 
    10 <ul> 
    11   <li each="x in dir(Html)" if="not x.startswith('__')">Html.${x}</li> 
    12   <li each="x in dir(Ajax)" if="not x.startswith('__')">Ajax.${x}</li> 
    13   <li each="x in dir(Url)" if="not x.startswith('__')">Url.${x}</li> 
     5  <AllDemoPages/> 
    146</ul> 
    157 
    16 <content name="stuff"> 
    17   <p>Hello world</p> 
    18   <p>${'yep'}</p> 
    19   <p>${str(3+4+5)}</p> 
    20   <p>${H('<hi></hi>')}</p> 
    21   ${Html} 
    22   ${foo} 
    23   ${H(quux)} 
    24 </content> 
    258 
    26 <use content="stuff"/> 
     9<p> 
     10  <em>Scrap code follows</em> 
     11</p> 
     12 
     13<h3>Some Python usage</h3> 
    2714 
    2815<p>There are ${str(products.Count)} products</p> 
     
    4027  </li> 
    4128</ul> 
     29 
     30#import clr 
     31<h3>clr module methods</h3> 
     32<ul> 
     33  <li each="x in dir(clr)">${x}</li> 
     34</ul> 
     35<h3>helper members and extension menthods</h3> 
     36<ul> 
     37  <li each="x in dir(Html)" if="not x.startswith('__')">Html.${x}</li> 
     38  <li each="x in dir(Ajax)" if="not x.startswith('__')">Ajax.${x}</li> 
     39  <li each="x in dir(Url)" if="not x.startswith('__')">Url.${x}</li> 
     40</ul> 
     41 
     42 
     43<h3>Script source code</h3> 
     44<code> 
     45  ${H(ScriptSource).replace("\r\n","<br/>").replace(" ", "&nbsp;")} 
     46</code> 
  • branches/scripting/src/Samples/AspNetMvc/IronPythonViews/Views/Layouts/Application.spark

    r231 r233  
    1 <html> 
     1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 
     2<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> 
    23  <head> 
    3     <global Title="'Python View Language Sample'"/> 
     4    <global type="string" Title="'IronPython Advanced Partials Demo'"/> 
    45    <title>${Title}</title> 
     6    <link type="text/css" rel="stylesheet" href="~/content/andreas08/andreas08.css"/> 
     7    <link type="text/css" rel="stylesheet" href="~/content/extra.css"/> 
     8    <use:head/> 
    59  </head> 
    610  <body> 
    7     <use:view/> 
     11    <div id="container" > 
     12      <div id="header"> 
     13        <h1>${H(Title)}</h1> 
     14        <h2>space reserved for your website slogan!</h2> 
     15      </div> 
     16      <div id="navigation"> 
     17        <macro:NavItem text="string" url="string"> 
     18          <li class="selected?{url == Context.Request.RawUrl}"><a href="${url}">${H(text)}</a></li> 
     19        </macro:NavItem> 
     20        ## use {content:navigation} to replace the entire menu 
     21        <use:navigation> 
     22          <ul> 
     23            ${NavItem("Home", Url.Action("index", "home"))} 
     24            ${NavItem("About", Url.Action("about", "home"))} 
     25            ## use {content:navextra} to add menu items 
     26            <use:navextra/> 
     27            ${NavItem("Style Guide", Url.Action("styleguide", "home"))} 
     28          </ul> 
     29        </use:navigation> 
     30      </div> 
     31 
     32      <div id="content"> 
     33        <use:view/> 
     34        ## use {content:splitcontentleft} or {content:splitcontentleft} to 
     35        ## produce this divided lower section 
     36        <test if="Content.ContainsKey('splitcontentleft') or Content.ContainsKey('splitcontentright')"> 
     37          <div class="splitcontentleft"> 
     38            <use:splitcontentleft/> 
     39          </div> 
     40          <div class="splitcontentright"> 
     41            <use:splitcontentright/> 
     42          </div> 
     43        </test> 
     44      </div> 
     45 
     46 
     47      <div id="subcontent"> 
     48        ## use {content:rightrail} to replace the right rail 
     49        <use:rightrail> 
     50          <DefaultRightrail/> 
     51        </use:rightrail> 
     52      </div> 
     53 
     54      <div id="footer"> 
     55        <p> 
     56          &copy; 2005-2006 <a href="#">Your Name</a> | Design by <a href="http://andreasviklund.com">Andreas Viklund</a> 
     57        </p> 
     58      </div> 
     59 
     60    </div> 
    861  </body> 
    962</html> 
  • branches/scripting/src/Samples/Samples.sln

    r231 r233  
    3737EndProject 
    3838Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Internationalization", "AspNetMvc\Internationalization\Internationalization.csproj", "{FB78D1AA-35C1-4B77-93F0-A3CC032CA70A}" 
    39 EndProject 
    40 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonViewLanguage", "PythonViewLanguage\PythonViewLanguage.csproj", "{22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC}" 
    4139EndProject 
    4240Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronPythonViews", "AspNetMvc\IronPythonViews\IronPythonViews.csproj", "{88AE48D2-9D28-4008-8CBC-64AAC13F96D1}" 
     
    108106                {FB78D1AA-35C1-4B77-93F0-A3CC032CA70A}.Release|Any CPU.ActiveCfg = Release|Any CPU 
    109107                {FB78D1AA-35C1-4B77-93F0-A3CC032CA70A}.Release|Any CPU.Build.0 = Release|Any CPU 
    110                 {22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 
    111                 {22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC}.Debug|Any CPU.Build.0 = Debug|Any CPU 
    112                 {22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC}.Release|Any CPU.ActiveCfg = Release|Any CPU 
    113                 {22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC}.Release|Any CPU.Build.0 = Release|Any CPU 
    114108                {88AE48D2-9D28-4008-8CBC-64AAC13F96D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 
    115109                {88AE48D2-9D28-4008-8CBC-64AAC13F96D1}.Debug|Any CPU.Build.0 = Debug|Any CPU 
     
    132126                {7565F57D-13FB-4164-B495-ABFD11C44554} = {B92F64C3-2A6F-4422-8B5B-12CE8CBF7E52} 
    133127                {FB78D1AA-35C1-4B77-93F0-A3CC032CA70A} = {B92F64C3-2A6F-4422-8B5B-12CE8CBF7E52} 
    134                 {22B2D07F-ED18-4AC2-BBE8-C58F1BE8E6BC} = {B92F64C3-2A6F-4422-8B5B-12CE8CBF7E52} 
    135128                {88AE48D2-9D28-4008-8CBC-64AAC13F96D1} = {B92F64C3-2A6F-4422-8B5B-12CE8CBF7E52} 
    136129                {123FBEA2-3323-4051-8F33-734F4C06DD6C} = {95C10F2D-8E28-4F30-BC13-53ADFF36C196}