Skip to content
This repository was archived by the owner on May 28, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions playapp-1.2.1-rythm-0.3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea
modules
*.iml
precompiled
tmp
23 changes: 23 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/controllers/Products.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package controllers;

import play.*;
import play.mvc.*;

import java.util.*;

import models.*;
import s.*;

import com.greenlaw110.rythm.play.UseRythmTemplateEngine;

@UseRythmTemplateEngine
public class Products extends Controller {
public static void index(int n) {
List<Product> products = Service.getProducts(n);
render(products);
}

public static void env() {
renderText(play.Play.configuration.get("application.mode"));
}
}
15 changes: 15 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/s/Category.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package s;

public class Category {
// Fields
private String name;

public String getName() {
return name;
}

public Category(String name) {
this.name = name;
}

}
33 changes: 33 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/s/Product.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package s;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;


public class Product {
// Fields
private String name;
private Integer price;
private String description;
private Set<Category> categories = new HashSet<Category>();

// Getters and setters
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public Integer getPrice() { return price; }
public void setPrice(Integer price) { this.price = price; }
public String getDescription() { return description; }
public void setDescription(String description) { this.description = description; }
public Set<Category> getCategories() { return categories; }
public void setCategories(Set<Category> categories) { this.categories = categories; }

// ctor
public Product(String name, Integer price, String description, Category... categories) {
this.name = name;
this.price = price;
this.description = description;
this.categories = new HashSet<Category>(Arrays.asList(categories));
}

}
34 changes: 34 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/s/Service.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package s;

import java.util.ArrayList;
import java.util.List;


public class Service {
private static List<Product> products = new ArrayList<Product>();
private static List<Category> categories = new ArrayList<Category>();;

static {
System.out.println("Creating products");

for (int i = 0; i < 5; i++) {
String name = Integer.toString(1000 + i);
categories.add(new Category(name));
}

for (int i = 0; i < 20000; i++) {
String name = Integer.toString(i);
String description = Integer.toString(i * i);

Product product = new Product(name, i, description);

product.getCategories().addAll(categories);
products.add(product);
}
}

public static List<Product> getProducts(int max) {
return products.subList(0, max);
}

}
19 changes: 19 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/views/errors/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>

<html>
<head>
<title>Not found</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
#{if play.mode.name() == 'DEV'}
#{404 result /}
#{/if}
#{else}
<h1>Not found</h1>
<p>
${result.message}
</p>
#{/else}
</body>
</html>
21 changes: 21 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/views/errors/500.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>

<html>
<head>
<title>Application error</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
<body>
#{if play.mode.name() == 'DEV'}
#{500 exception /}
#{/if}
#{else}
<h1>Oops, an error occured</h1>
#{if exception instanceof play.exceptions.PlayException}
<p>
This exception has been logged with id <strong>${exception.id}</strong>.
</p>
#{/if}
#{/else}
</body>
</html>
42 changes: 42 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/views/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#{verbatim}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>@get("title")</title>

<link rel="stylesheet" media="screen" href="/public/default.css">
@renderSection("moreStyles")
<link rel="shortcut icon" type="image/png" href="public/images/favicon.png">
@renderSection("moreScripts")
</head>

<body>
<div id="maincontainer">
<div id="topsection">
<div class="innertube"><h1>Company Title .....</h1></div>
</div>
<div id="contentwrapper">
<div id="contentcolumn">

<!-- Page name needs to be injected -->
<div><h2>@get("pagename")</h2></div>
<div class="innertube">
@doLayout
</div>
</div>
</div>

<div id="leftcolumn">
<div class="innertube">
<h3>Side bar.....</h3>
</div>
</div>

<div id="footer">footer.....</div>
</div>
</body>
</html>
#{/verbatim}
17 changes: 17 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/views/products/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
@import s.*;
@args List<Product> products;
@extends("main.html")
@set("title": "Product listing")
@set("pagename": "Product listing")

<table>
@for(Product prod: products) {
<tr>
<td>@product(prod)</td>
<td>
@for(Category category: prod.getCategories()) @category.getName(), @
</td>
</tr>
}
</table>

6 changes: 6 additions & 0 deletions playapp-1.2.1-rythm-0.3/app/views/tags/rythm/product.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@import s.*;
@args Product prod;
<div class="product">
<img src="@(prod.getName()).jpg" />
<span class="productname">@prod.getName()</span>, <span class="price">$@prod.getPrice()</span>
</div>
Loading