Skip to content
Ryan Neufeld edited this page Jul 9, 2013 · 12 revisions

In Part 1 of this tutorial, we will build a simple application with a counter and a button that allows us to increment the counter. We will make it so that any number of users will be able to connect to the same server, and everyone will see everyone else's counter. In Part 2 we will turn this application into a game.

Most of the work for this project will be built upon pedestal-app with a very small amount of pedestal-service work. The first step is create a pedestal-app project.

Creating a new project

Pedestal-app's template generates a new project with a minimal working application. As you go through this tutorial, you will learn the purpose of each generated file.

We will organize all of the work for this tutorial under one directory named pedestal-app-tutorial. This directory will eventually contain the client and service projects.

mkdir pedestal-app-tutorial
cd pedestal-app-tutorial
lein new pedestal-app tutorial-client no-comment
cd tutorial-client

The command lein new pedestal-app tutorial-client no-comment will create a new application project named tutorial-client. The no-comment argument will generate a project without all of the explanatory comments.

Before making any modifications, start the new project and take a look around.

From within the tutorial-client directory, run:

lein repl

and then in the REPL

(use 'dev)
(start)

Open a browser and navigate to http://localhost:3000. The default index page describes the layout of the project and some of the included tools. This project hosts a very simple "Hello World" application. To run the actual application, go to http://localhost:3000/tutorial-client-dev.html.

To see the various aspects of the project, use the Tools Menu in the lower right corner of the browser window (hover the mouse in the lower right corner to make the tools menu appear). As we go through this tutorial, the proper use of each aspect will become clear.

What is this project?

A pedestal-app project is a set of tools to help you build a single-page application. These tools do things like compile your code, generate host pages and allow you to view different aspects of your application in isolation. The output of these tools is a set of artifacts which can be deployed.

It is easy to get confused about the nature of this project because it includes a web server. You might be tempted to think that this is a project with both a front- and back-end. The web server included in this project is used only as a development tool. The artifacts produced by this project are static files which may be placed on S3 or served by some other service. These files will be compiled to out/public. The main point is not to confuse the web server in the application project with web services that will be built in their own isolated projects.

Next Steps

In the next section, you will add a simple counter to this new application.

The tag for this section is v2.0.0.

Home | Making a Counter

Clone this wiki locally