Академический Документы
Профессиональный Документы
Культура Документы
4
The Escapers 2008
Draft One
Contents
Introduction! 5
What’s all this then?! 6
Site Manager! 6
The Inspector! 8
Getting Started! 9
Divs! 12
Introduction! 24
Getting started! 24
Ruby on Rails™! 28
Introduction! 28
Getting started! 28
Controller! 30
Concepts! 42
Basics! 51
Movie options! 54
XHTML is the W3C specification for designing web pages, it's a fully documented, validated way of creating
web pages which is supported by all modern web browsers. CSS (Cascading Style Sheets) is a specification
for adding style to XHTML (and other) documents, so all page content can be held in XHTML, and all styl-
ing information can be held in the CSS file, making for a simple and more clean site structure.
Flux brings XHTML, CSS and an easy Mac interface together to let novices and professionals create amaz-
ing websites.
What’s all this then?
Site Manager
The Site Manger is Flux, is, unsurprisingly , where the whole site is managed. You can create new files, delete them, rename them
and edit them, all from this window.
The Page Designer is where all CSS and XHTML is edited, you can drag, drop, copy and paste images,text and elements onto
your page.
You can now pick a name for the folder in which your website will be created, it can be any name you like, this file name is only
used to save the files on your Mac, so you don't need to worry about website naming conventions. Names like “My first web-
site”, or “John's holiday blog” are fine.
You can also choose a location on your computer to put this folder, your Desktop, Home directory, or anywhere else you like.
You also need to choose if you want a Standard website, or a Ruby on Rails based website, if you're not sure which you need,
use “Standard website”.
So now you have a single XHTML file called “index.html” and a single CSS file called “main.css” in your website, Flux will create a
thumbnail preview for each XHTML file, and as you can see, at the moment, the preview is plain white as the page is empty. You
can now double-click “index.html” to open up the page ready for editing.
The div can be freely resized and moved by dragging by the centre
of the div to move it, and the circular “handles” on the sides and
corners to resize it. We can also add some basic styling to the div
using the “Inspector”. The Inspector can add styling to items such as
divs without using CSS files, instead the styling is held within the
XHTML, this is good for quickly creating and experimenting with
styles, if you decide to move the style into the CSS file, Flux can do this for you very easily by choosing the
“Create style with...” option in the contextual menu.
The Inspector provides many different options for modifying the div, such as borders, fill, and many different styles. We will start
by giving the div a fill colour.
You can have different styles of border, solid, dotted, dashed etc. You can also vary the thickness and colour borders. You can also
have a different borders on each of the 4 sides of a div, as can be seen in this rather over the top example:
You can display or hide spans at any time and you can also erase them just like normal text if you decide you don't want them.
CSS can either be referenced externally using a .css file, or used inline to style individual objects, Flux supports both these
methods, but it’s often considered good practice to use an external file, as this allows you to experiment with different designs,
tailor your site to meet the needs of different groups of users (for example, you could have a different CSS file for partially
sighted users, which could use larger fonts and higher contrast colors), and keep your XHTML easy to read.
1. You need a web page, you can create one easily in the the ‘File Manager’
2. You also need a CSS file, this can also be created in the ‘File Manager’
You can find out how to create these files in the ‘Getting Started’ section of this manual.
Depending on how you have created your two files, the CSS may, or may not, already be associated with the XHTML page, if it is
already associated, then you can skip the next section.
2. Drag the CSS file from the File Manager to the CSS area of the Page Designer.
Once you have dropped the CSS file on this area, all the Style definitions will appear in this list.
Now, save the file, and you have just associated a CSS file with your webpage.
A CSS file can be associated to more than one XHTML document, doing this is a great way of retaining a common look and feel
across pages.
An XHTML file can have more than one CSS file associated to it.
The first style we will make will be a ‘class’ style, this is probably the most common type of style, as it’s very versatile and can be
applied to most types of elements.
Creating a new style is simple, first, select the CSS file you want to create the definition in, if you’ve just followed the above tu-
torial, you will only have one, so click on that.
Once you have selected the destination file for your new style definition, click
the ‘+’ button to create a new ‘Empty’ style.
You will be asked if you want to base the style on the selected object, for the
purposes of this tutorial, press ‘No’.
Once the new style has been created, the style will be automatically selected
for renaming, and unless you want the style to be called ‘UntitledStyle’, we
click! suggest you give it a name relevant to it’s intended purpose, for example
‘myPriceBadge’.
Since we opted to create and empty style, you will notice that none of the
style’s sections are enabled, so the style will do nothing at the moment.
ID - ID styles are preceded by a ‘#’, and to make an element adopt an ID style, the ‘id’ attribute should be set in the element,
rather the ‘class’ attribute.
So what’s the difference between a class and an id style? Don’t they just do the same thing? Well, yes, apart from an ID style
should only be used once in a single document, i.e. for elements that need a unique identity,.
Override - These styles are used to change the styling of all elements of a particular type, for example, in the screen capture be-
low, we have created a ‘div’ style, the only attribute the style has is ‘Color’, so every new ‘Div’ we create will adopt it’s color
from this value (unless it is overridden by another style definition or inline styling).
The screengrab below illustrates this techinque, the first image (the
grid), creates a simple background for the element, and second im-
age (diagonal stripes) is just just applied to the top of the element.
This is a very effective technique to create innovative and attractive designs, for example, the first image could be an attractive
damask pattern, and the second image could be a simple, semi-transparent gradient. This keeps the size of the images very small,
and is very versatile, as you could change just one of the images to create quite a different effect.
There are two main drawbacks to this approach, the first being Internet Explorers’s poor support for CSS, it does not support
alpha channels in images, thus ruling out our attractive fade graphic.
In summary, although multiple images can help create very attractive,bandwidth-friendly designs, it’s support is very sparse, so
unless your audience is using the very best, most up-to-date web browsers, The Escapers do not recommend you use this tech-
nique.
Introduction
Flux has some built-in image effects that you can use to enhance and change images used on your website, most of these effects
are based on Apple's “Core Image” technology, and consequently will make good use of any acceleration hardware you have in
your Mac.
The “Effects” window is available on the toolbar on the Site Manager window, and this is where you can access all of the graphi-
cal effects available in Flux.
Getting started
To get started with image effects in Flux, you'll need an image in your website, you can put an image into your website by simply
dragging a file from the Finder onto the Site Manager, you can drop the file over a certain folder to put the file into that folder.
Once you have an image in the Site Manager, you can click on the image to select it, and then click on the Effects button to open
up the image into the Effects editor.
Websites based on Ruby on Rails tend to have a different layout to most websites, this layout can be tricky to get right, so Rails
comes with some command line tools to make the layout for you. However, if you don't want to use the command line tools di-
rectly, you can achieve most of the same results by using Flux's features for creating Rails based websites.
Getting started
To get started with creating a Ruby on Rails based website, first select “New” from the “File” menu in Flux.
In the usual “New file” sheet, you can choose from the “Project Type” popup menu to create a Rails based website. Now press
“Save” as usual, and your website will be created.
Flux uses the built-in Ruby on Rails installation on your Mac (Mac OS X 10.5 has Rails built-in, but if you are using Tiger, you will
need to install it separately) to create a new website. You will notice that the structure of the site is somewhat more compli-
cated than a standard website created with Flux.
You will also notice a couple of new buttons on the Site Manager. First,
there is a switch, which can be used to start and stop the built-in Rails
server on your Mac, it is set to off by default, but can be turned on by sim-
ply clicking the switch. When the Rails server is started, the small light by
Once you have created your website in Flux, we can add web pages and Ruby code to make
it functional. Rails-based websites differ from standard websites because they have Ruby files
in them, as well as the usual XHTML, CSS, and Javascript files. The Ruby files are held in particular folders so that the Rails server
knows where to find them. To get started, we need to start adding Ruby files to our website, starting with a “controller”.
Controller
Controllers in Rails based websites should be considered the “backbone” of the website, that is to say they are in “control” of
your web application. To make a Controller, we can press the “Advanced...” button at the bottom of the Site Manager.
Once the index page is created, you can double-click to open it into the Page Editor like any other web page.
Flux does this to keep Ruby code in usable chunks, as the stan-
dard way of writing Ruby on Rails code in XHTML does not pro-
vide any way of know when the Ruby starts and ends. It is this na-
ture of Ruby on Rails which makes it very easy to integrate into
XHTML as you can have tiny snippets of Ruby code in your pages
to control minute details of appearance and content.
<p>Hello!<br/></p>
Hit, Apple-S to save, and now press “Preview”. If it’s not already running, Flux will ask you if you want to start your Ruby server,
answer “Yes”.
Now, when you web page is displayed, it’s interpreted by your Ruby server first and displayed, so instead of getting “Hello!”,
you’ll get “Hello!” printed 10 times:
Step 1 – Create a new project as described in the 'Getting Started' chapter, or open an ex-
isting project.
Step 2 – Once you have created the new project, we need to install the MooFX toolkit
into this project, the easiest way to do this is described in the 'Packages' chapter.
Step 3 – Open your web page by double clicking the file in the Site Manager.
Step 4 – Import the required JavaScript files into your page using the 'Page Attributes'
panel, and drag the the javascript files from the site manager to the 'Javascript' list. Instead
of dragging, you can also choose the JavaScript file from the ‘+’ popup menu.
First, we need a div to attach an action to, you can do this by ei-
ther creating a div, or a very easy way to make a div with some
content is just to drag an image from your Desktop/Finder onto
the page, then a new div will be created containing the picture.
For most effects, you'll need to give the div and “id” attribute, and
that can be done using the Inspector, by adding an “id” attribute.
We'll give this div the attribute “knut”, as this is the name of the
polar bear in the picture.
You will see an icon appear in the bottom left of the div signifying that there
is an “onClick” action attached.
These ‘Action’ icons have no effect on the functionality of the actions, they
are just a handy indicator to tell you which elements have actions attached.
AJAX is increasing in popularity as it not only makes websites feel more like responsive applications, but it also reduces band-
width and load on servers, as to update content on a page can be a very small amount of data, rather than force a complete re-
load.
http://www.mozilla.org/projects/security/components/same-origin.html
Getting started
AJAX services are built in to all modern web browsers, and your web server needs no special considerations to be used to
server AJAX requests. AJAX services differ between some web browsers, so it's a good idea to use a library which masks these
differences and gives you maximum compatibility with as many web browsers as possible.
For this example, we're going to use the “jQuery” toolkit, this is a very powerful and very popular Javascript library which
amongst many great features, has superb AJAX functionality which is very simple to use. Flux comes with built-in support for
jQuery, and you can use the “Toolkits” window to add AJAX functionality to your page in just a few mouse clicks.
To use jQuery, you will need to first install the jQuery Javascript library. This can be done by either downloading it from
http://jquery.com/ or if you prefer, use the “Packages” functionality in Flux to install jQuery for you. You can read about how to
use Packages in the the Packages section of this manual.
Once you have the jQuery Javascript file in your project, either by dragging it from the Finder onto the Site Manager, or by using
Packages, you need to tell Flux that you are going to use it on your page, this makes sure that a reference to the Javascript file
will be in the XHTML file that Flux creates. To do this, you need to drag the jQuery Javascript file from the Site Manager in the
the “Javascript” section of “Page Attributes”, you can access this with the “Page Attributes” button on the document’s toolbar.
When you have Page Attributes open, switch to the Javascript tab, and drag over the jQuery Javascript file.
To quickly use AJAX, first create a div, select it, and choose “Attach Action...” from the contextual menu.
For this example, you will need to install jQuery as described in the first example, unless you choose to use the site created in
the first example, in which case jQuery is already installed and ready to use.
Now you can use the “Attach Action...” contextual menu again, but this time, we choose another callback function, which can
populate the contents of a div, and change the callback function to reference “mybox” as shown below:
Basics
Embedding a Movie in Flux is as simple as dragging a Movie from the Finder to your page.
When you drop the Movie on the page, you will be asked wether you want to link the file into your project, or copy it.
Linking a file will make a reference to Movie in your project using a symbolic link, this is useful if your movie is very large, or you
simply don't want multiple copies of the movie on your disk, however, your project will no longer be self contained, so take care
if you are moving it to a different machine or backing it up.
Copying a file will make a copy of the Movie in your project, just like the rest of your resources like images or CSS files.