├── blog
├── README.md
├── app
│ ├── _includes
│ │ └── footer.html
│ ├── _layouts
│ │ ├── post.html
│ │ └── default.html
│ ├── style.less
│ ├── index.html
│ └── posts
│ │ ├── third.md
│ │ ├── first.md
│ │ └── second.md
├── src
│ ├── main
│ │ └── java
│ │ │ └── net
│ │ │ └── codestory
│ │ │ └── HelloWorldServer.java
│ └── test
│ │ └── java
│ │ └── net
│ │ └── codestory
│ │ └── HelloWorldServerTest.java
└── pom.xml
├── angular
├── README.md
├── app
│ ├── style.less
│ ├── app.coffee
│ └── index.html
├── src
│ ├── main
│ │ └── java
│ │ │ └── net
│ │ │ └── codestory
│ │ │ └── AngularServer.java
│ └── test
│ │ └── java
│ │ └── net
│ │ └── codestory
│ │ └── AngularTest.java
└── pom.xml
├── helloworld
├── README.md
├── app
│ ├── hello.less
│ └── index.html
├── src
│ ├── main
│ │ └── java
│ │ │ └── net
│ │ │ └── codestory
│ │ │ └── HelloWorldServer.java
│ └── test
│ │ └── java
│ │ └── net
│ │ └── codestory
│ │ └── HelloWorldTest.java
└── pom.xml
└── README.md
/blog/README.md:
--------------------------------------------------------------------------------
1 | Blog sample.
2 |
--------------------------------------------------------------------------------
/angular/README.md:
--------------------------------------------------------------------------------
1 | Sample AngularJs application
2 |
--------------------------------------------------------------------------------
/blog/app/_includes/footer.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/helloworld/README.md:
--------------------------------------------------------------------------------
1 | Classic "Hello World" sample.
2 |
--------------------------------------------------------------------------------
/helloworld/app/hello.less:
--------------------------------------------------------------------------------
1 | body {
2 | margin-top: 70px;
3 |
4 | a {
5 | text-decoration: underline;
6 | }
7 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | This is a list of samples that demonstrate how to use [fluent-http](https://github.com/CodeStory/fluent-http).
2 |
--------------------------------------------------------------------------------
/angular/app/style.less:
--------------------------------------------------------------------------------
1 | [ng-cloak], .ng-cloak {
2 | display: none !important;
3 | }
4 |
5 | body {
6 | margin-top: 70px;
7 |
8 | a {
9 | text-decoration: underline;
10 | }
11 | }
--------------------------------------------------------------------------------
/blog/src/main/java/net/codestory/HelloWorldServer.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import net.codestory.http.WebServer;
4 |
5 | public class HelloWorldServer {
6 | public static void main(String[] args) {
7 | new WebServer().start();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/helloworld/src/main/java/net/codestory/HelloWorldServer.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import net.codestory.http.WebServer;
4 |
5 | public class HelloWorldServer {
6 | public static void main(String[] args) {
7 | new WebServer().start();
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/blog/app/_layouts/post.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | ---
4 |
5 |
6 |
7 | [[title]]
8 |
9 |
10 |
11 | [[body]]
12 |
13 |
14 |
17 |
--------------------------------------------------------------------------------
/angular/app/app.coffee:
--------------------------------------------------------------------------------
1 | angular.module 'demo', []
2 |
3 | .controller 'DemoController', class
4 | constructor: (@$http) ->
5 | @name = 'world'
6 | @refresh()
7 |
8 | refresh: ->
9 | if @name == ''
10 | @greeting = ''
11 | return
12 |
13 | @$http.get("/hello/#{@name}").success (data) =>
14 | @greeting = data
--------------------------------------------------------------------------------
/blog/app/style.less:
--------------------------------------------------------------------------------
1 | @grey: rgb(250, 250, 250);
2 |
3 | body {
4 | margin-top: 70px;
5 |
6 | .container {
7 | min-height: 1000px;
8 |
9 | .panel {
10 | .panel-heading {
11 | font-weight: bold;
12 | }
13 |
14 | .panel-body {
15 | text-align: justify;
16 | }
17 | }
18 | }
19 |
20 | footer {
21 | background-color: @grey;
22 | height: 300px;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/helloworld/app/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Hello World
4 | ---
5 |
6 | [[webjar 'bootstrap.css']]
7 | [[css 'hello']]
8 |
9 |
10 |
11 |
Hello, world!
12 |
13 |
This is a very basic sample of web application with
14 | fluent-http.
15 |
16 |
17 |
--------------------------------------------------------------------------------
/blog/app/_layouts/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | [[title]]
6 | [[webjar 'bootstrap.css']]
7 | [[css 'style']]
8 | [[livereload]]
9 |
10 |
11 |
12 |
13 |
Blog
14 |
15 |
Fluent-http can be used in a way very similar to Jekyll
16 |
17 |
18 | [[body]]
19 |
20 |
21 | [[>footer]]
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/angular/src/main/java/net/codestory/AngularServer.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import net.codestory.http.*;
4 | import net.codestory.http.routes.*;
5 |
6 | public class AngularServer {
7 | public static void main(String[] args) {
8 | new WebServer().configure(new WebConfiguration()).start();
9 | }
10 |
11 | public static class WebConfiguration implements Configuration {
12 | @Override
13 | public void configure(Routes routes) {
14 | routes.get("/hello/:name", (context, name) -> "Hello, " + name.toUpperCase() + "!");
15 | }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/helloworld/src/test/java/net/codestory/HelloWorldTest.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import net.codestory.http.*;
4 | import net.codestory.simplelenium.*;
5 |
6 | import org.junit.*;
7 |
8 | public class HelloWorldTest extends SeleniumTest {
9 | WebServer webServer = new WebServer().startOnRandomPort();
10 |
11 | @Override
12 | public String getDefaultBaseUrl() {
13 | return "http://localhost:" + webServer.port();
14 | }
15 |
16 | @Test
17 | public void display_hello_world() {
18 | goTo("/");
19 |
20 | find(".jumbotron")
21 | .find("h1").should().contain("Hello, world!")
22 | .find("p").should().contain("This is a very basic sample of web application");
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/angular/app/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Hello World
4 | ng-app: demo
5 | ---
6 |
7 | [[webjar 'bootstrap.min.css']]
8 | [[css 'style']]
9 |
10 |
11 |
12 |
{{demo.greeting}}
13 |
14 |
15 | This is a sample of application with
16 | fluent-http
17 | and
18 | AngularJs.
19 |
20 |
21 |
24 |
25 |
26 |
27 |
28 | [[webjar 'angular.min.js']]
29 | [[script 'app']]
30 |
--------------------------------------------------------------------------------
/blog/app/index.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | title: Hello World
4 | ---
5 |
6 |
7 |
8 |
Archives:
9 |
10 | [[#each site.categories.posts]]
11 | - [[title]]
12 | [[/each]]
13 |
14 |
15 |
16 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/angular/src/test/java/net/codestory/AngularTest.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import static net.codestory.AngularServer.*;
4 |
5 | import net.codestory.http.*;
6 | import net.codestory.http.misc.*;
7 | import net.codestory.simplelenium.*;
8 |
9 | import org.junit.*;
10 |
11 | public class AngularTest extends SeleniumTest {
12 | static WebServer webServer = new WebServer() {
13 | @Override
14 | protected Env createEnv() {
15 | return Env.prod();
16 | }
17 | }.configure(new WebConfiguration()).startOnRandomPort();
18 |
19 | @Override
20 | public String getDefaultBaseUrl() {
21 | return "http://localhost:" + webServer.port();
22 | }
23 |
24 | @Test
25 | public void display_hello_world() {
26 | goTo("/");
27 |
28 | find("h1").should().contain("Hello, WORLD!");
29 | }
30 |
31 | @Test
32 | public void change_name() {
33 | goTo("/");
34 |
35 | find("#name").clear().fill("Bob");
36 |
37 | find("h1").should().contain("Hello, BOB!");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/blog/app/posts/third.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | title: And again
4 | category: posts
5 | tags: ['java', 'web']
6 | ---
7 |
8 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec elementum ligula mauris, vel consequat sem luctus nec.
9 | Nullam ullamcorper accumsan tortor nec bibendum. Nam blandit, sapien et faucibus congue, metus neque sollicitudin elit,
10 | eget tempor libero enim sit amet lectus. In sed erat tincidunt, fringilla tortor sit amet, vestibulum tortor. Suspendisse
11 | feugiat sed neque vitae tincidunt. Curabitur porttitor id dui quis bibendum. Curabitur at erat sed leo accumsan lacinia
12 | eu in neque. Phasellus tristique feugiat justo sit amet condimentum. Aliquam augue odio, pulvinar ac iaculis sed, cursus
13 | nec tellus. Aenean non condimentum turpis. Nam erat lectus, ornare at sem laoreet, varius tincidunt ante.
14 |
15 | Nunc mollis rutrum tristique. Quisque elementum luctus commodo. Suspendisse condimentum diam lectus, quis interdum est
16 | ornare eu. Nunc eros quam, tempor non tellus eu, tincidunt commodo dolor. Etiam eu ante in mauris lacinia accumsan quis
17 | in libero. Proin sit amet urna tincidunt eros semper porta. Aliquam in posuere eros, quis dapibus erat. Integer posuere
18 | tortor quis arcu consequat pulvinar eu sit amet nunc. Nunc eget sem sit amet ante luctus scelerisque eget eu sapien.
19 |
--------------------------------------------------------------------------------
/blog/app/posts/first.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | title: A nice Lorem ipsum
4 | category: posts
5 | tags: java, javascript, coffee
6 | ---
7 |
8 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec elementum ligula mauris, vel consequat sem luctus nec.
9 | Nullam ullamcorper accumsan tortor nec bibendum. Nam blandit, sapien et faucibus congue, metus neque sollicitudin elit,
10 | eget tempor libero enim sit amet lectus. In sed erat tincidunt, fringilla tortor sit amet, vestibulum tortor. Suspendisse
11 | feugiat sed neque vitae tincidunt. Curabitur porttitor id dui quis bibendum. Curabitur at erat sed leo accumsan lacinia
12 | eu in neque. Phasellus tristique feugiat justo sit amet condimentum. Aliquam augue odio, pulvinar ac iaculis sed, cursus
13 | nec tellus. Aenean non condimentum turpis. Nam erat lectus, ornare at sem laoreet, varius tincidunt ante.
14 |
15 | Nunc mollis rutrum tristique. Quisque elementum luctus commodo. Suspendisse condimentum diam lectus, quis interdum est
16 | ornare eu. Nunc eros quam, tempor non tellus eu, tincidunt commodo dolor. Etiam eu ante in mauris lacinia accumsan quis
17 | in libero. Proin sit amet urna tincidunt eros semper porta. Aliquam in posuere eros, quis dapibus erat. Integer posuere
18 | tortor quis arcu consequat pulvinar eu sit amet nunc. Nunc eget sem sit amet ante luctus scelerisque eget eu sapien.
19 |
--------------------------------------------------------------------------------
/blog/app/posts/second.md:
--------------------------------------------------------------------------------
1 | ---
2 | layout: post
3 | title: Yet another Lorem ipsum
4 | category: posts
5 | tags: ['java', 'web', 'c#']
6 | ---
7 |
8 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec elementum ligula mauris, vel consequat sem luctus nec.
9 | Nullam ullamcorper accumsan tortor nec bibendum. Nam blandit, sapien et faucibus congue, metus neque sollicitudin elit,
10 | eget tempor libero enim sit amet lectus. In sed erat tincidunt, fringilla tortor sit amet, vestibulum tortor. Suspendisse
11 | feugiat sed neque vitae tincidunt. Curabitur porttitor id dui quis bibendum. Curabitur at erat sed leo accumsan lacinia
12 | eu in neque. Phasellus tristique feugiat justo sit amet condimentum. Aliquam augue odio, pulvinar ac iaculis sed, cursus
13 | nec tellus. Aenean non condimentum turpis. Nam erat lectus, ornare at sem laoreet, varius tincidunt ante.
14 |
15 | Nunc mollis rutrum tristique. Quisque elementum luctus commodo. Suspendisse condimentum diam lectus, quis interdum est
16 | ornare eu. Nunc eros quam, tempor non tellus eu, tincidunt commodo dolor. Etiam eu ante in mauris lacinia accumsan quis
17 | in libero. Proin sit amet urna tincidunt eros semper porta. Aliquam in posuere eros, quis dapibus erat. Integer posuere
18 | tortor quis arcu consequat pulvinar eu sit amet nunc. Nunc eget sem sit amet ante luctus scelerisque eget eu sapien.
19 |
--------------------------------------------------------------------------------
/blog/src/test/java/net/codestory/HelloWorldServerTest.java:
--------------------------------------------------------------------------------
1 | package net.codestory;
2 |
3 | import net.codestory.http.WebServer;
4 | import net.codestory.simplelenium.SeleniumTest;
5 | import org.junit.Test;
6 |
7 | import static org.assertj.core.api.Assertions.assertThat;
8 |
9 | public class HelloWorldServerTest extends SeleniumTest {
10 | static WebServer webServer = new WebServer().startOnRandomPort();
11 |
12 | @Override
13 | protected String getDefaultBaseUrl() {
14 | return "http://localhost:" + webServer.port();
15 | }
16 |
17 | @Test
18 | public void archives() {
19 | goTo("/");
20 |
21 | find("#archives a").should()
22 | .haveSize(3)
23 | .contain("A nice Lorem ipsum", "Yet another Lorem ipsum", "And again");
24 | }
25 |
26 | @Test
27 | public void tags() {
28 | goTo("/");
29 |
30 | find("#tags #coffee").should().haveSize(1);
31 | find("#tags #java").should().haveSize(1);
32 | }
33 |
34 | @Test
35 | public void post() {
36 | goTo("/");
37 |
38 | find("a").withText("A nice Lorem ipsum").click();
39 |
40 | find(".panel-heading").should().contain("A nice Lorem ipsum");
41 | find(".panel-body").should().contain("Lorem ipsum dolor sit amet, consectetur adipiscing elit.");
42 | }
43 |
44 | @Test
45 | public void from_post_to_index() {
46 | goTo("/posts/first");
47 |
48 | find("a").withText("Back to index").click();
49 |
50 | assertThat(path()).isEqualTo("/");
51 | }
52 | }
--------------------------------------------------------------------------------
/helloworld/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | net.code-story
8 | sample-helloworld
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 3
13 |
14 |
15 |
16 | UTF-8
17 | 1.8
18 | 1.8
19 |
20 |
21 |
22 |
23 |
24 | maven-jar-plugin
25 | 2.4
26 |
27 |
28 |
29 | true
30 | dependency
31 | net.codestory.HelloWorldServer
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | net.code-story
42 | http
43 | 2.68
44 |
45 |
46 | org.webjars
47 | bootstrap
48 | 3.3.2
49 |
50 |
51 |
52 | junit
53 | junit
54 | 4.12
55 | test
56 |
57 |
58 | net.code-story
59 | simplelenium
60 | 1.34
61 | test
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/blog/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | net.code-story
8 | sample-blog
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 3
13 |
14 |
15 |
16 | UTF-8
17 | 1.8
18 | 1.8
19 |
20 |
21 |
22 |
23 |
24 | maven-jar-plugin
25 | 2.4
26 |
27 |
28 |
29 | true
30 | dependency
31 | net.codestory.HelloWorldServer
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 | net.code-story
42 | http
43 | 2.68
44 |
45 |
46 | org.webjars
47 | bootstrap
48 | 3.3.2
49 |
50 |
51 |
52 | junit
53 | junit
54 | 4.12
55 | test
56 |
57 |
58 | net.code-story
59 | simplelenium
60 | 1.34
61 | test
62 |
63 |
64 | org.assertj
65 | assertj-core-java8
66 | 1.0.0m1
67 | test
68 |
69 |
70 |
71 |
--------------------------------------------------------------------------------
/angular/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | net.code-story
8 | sample-angular
9 | 1.0-SNAPSHOT
10 |
11 |
12 | 3
13 |
14 |
15 |
16 | UTF-8
17 | 1.8
18 | 1.8
19 |
20 |
21 |
22 | web
23 |
24 |
25 | maven-jar-plugin
26 | 2.4
27 |
28 |
29 |
30 | true
31 | dependency
32 | net.codestory.AngularServer
33 |
34 |
35 |
36 |
37 |
38 | org.apache.maven.plugins
39 | maven-dependency-plugin
40 | 2.8
41 |
42 |
43 | copy-dependencies
44 | package
45 |
46 | copy-dependencies
47 |
48 |
49 | compile
50 | runtime
51 | ${project.build.directory}/dependency
52 | false
53 | false
54 | true
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | net.code-story
65 | http
66 | 2.68
67 |
68 |
69 | org.webjars
70 | bootstrap
71 | 3.3.2
72 |
73 |
74 | org.webjars
75 | angularjs
76 | 1.3.11
77 |
78 |
79 |
80 | junit
81 | junit
82 | 4.12
83 | test
84 |
85 |
86 | net.code-story
87 | simplelenium
88 | 1.34
89 | test
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------