:Website-In-A-Box

From ASUW Wiki
Revision as of 16:05, 6 June 2007 by Asuwtech (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The Website-In-A-Box software was originally developed in Spring 2006 by Joshua Schripsema, the ASUW Tech from 2004-2007. This software allows wiki-style editing of standalone websites so that people with no knowledge of HTML can do basic maintenance of their websites. It is a template driven system with some default replacement names.

Here I will attempt to provide a complete, thorough documentation of this project for future maintenance.

Contents

mySQL Code

In order to setup the database you can execute the following SQL code, run with phpMyAdmin, making sure to replace the following strings with their appropriate replacement.

-host-
The host, where the site will be kept. For example: the host portion of www.asuw.org is www
-DatabaseName-
The name of the database to use. I tend to use host_site where host is the same as above and the word site is just as it is. For example: www_site.
--
-- Create Database
--

CREATE DATABASE `-DatabaseName-` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `-DatabaseName-`;

-- 
-- Table structure for table `ExtMap`
-- 

CREATE TABLE `ExtMap` (
  `MapID` mediumint(9) NOT NULL auto_increment,
  `File` tinytext NOT NULL,
  `Ext` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`MapID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

-- --------------------------------------------------------

-- 
-- Table structure for table `PageInfo`
-- 

CREATE TABLE `PageInfo` (
  `PageID` mediumint(8) unsigned NOT NULL auto_increment,
  `SiteID` smallint(6) NOT NULL default '0',
  `FullTitle` tinytext NOT NULL,
  `ShortTitle` tinytext NOT NULL,
  `PageAdmin` text NOT NULL,
  `PageData` longtext NOT NULL,
  PRIMARY KEY  (`PageID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

INSERT INTO `PageInfo` VALUES (NULL, 1, 'How To Update', 'howtoupdate', 'asuwtech,trite', '==How To Update This Site==\r\n\r\nTo enter admin mode, click the small invisible square on the bottom right. Watch your cursor, when it changes to a click icon you can click on it. Also, if you have trouble finding it you can highlight the page and it should show up. If you don''t want to do all that trouble you can always just go to the address [<SiteRoot>admin/ http://-host-.asuw.org<SiteRoot>admin/]\r\n\r\n===Formatting Commands===\r\n\r\nAnything in ''''italics'''' should be replaced with the appropriate value. If there are [mailto:asuwtech@u.washington.edu any questions ask me.]\r\n\r\n;Main Headers: Surround with =.,.=''''text''''=.,.=\r\n;Sub Headers: Surround with =.,.=.,.=''''text''''=.,.=.,.=\r\n;Sub-Sub Headers: Surround with =.,.=.,.=.,.=''''text''''=.,.=.,.=.,.=\r\n;Bold: Surround with ''.,.''.,.''.,.''''text''''.,.''.,.''.,.''. Three ''''single'''' quotes. Example: ''''''text''''''\r\n;Italic: Surround with ''.,.''.,.''''text''''.,.''.,.''. Two ''''single'''' quotes. Example: ''''text''''\r\n;Small: Surround with ~.,.~''''text''''~.,.~ Example: ~~text~~\r\n;Big: Surround with `.,.`''''text''''`.,.` Example: ``text``\r\n;Align: There are three align tags -.,.-.,.-''''text''''-.,.-, -.,.-''''text''''-.,.-, -.,.-''''text''''-.,.-.,.-. Used to align paragraphs or images to the left, center, or right respectively.\r\n;Indents: To indent a line - prefix it with :, the : must start the line. Can be either single (:) or double (::).  Example:\r\n: This line is single indented.\r\n:: This line is double indented.\r\n\r\n===Lists===\r\n\r\nLists were easily the most pain in the ass thing to program, luckily they aren''t that bad to create. To use, begin the line with either a * or # depending on what kind of list you want. Also lists can be multi-level and mixed. It is easiest to learn from an example:\r\n\r\n.,.* Item 1<br />\r\n.,.* Item 2<br />\r\n.,.*# Item 2a<br />\r\n.,.*# Item 2b<br />\r\n.,.*#* Item 2b(i)<br />\r\n.,.* Item 3\r\n\r\n~~''''''Appears like:''''''~~\r\n\r\n* Item 1\r\n* Item 2\r\n*# Item 2a\r\n*# Item 2b\r\n*#* Item 2b(i)\r\n* Item 3\r\n\r\n;Definition List: There is an additional list type called a definition list. ''''''This'''''' line is actually a definition list consisting of a word and a definition.\r\n\r\n;word:definition\r\n\r\nIt can be specified by starting a line with ; and then putting "word" and then using : and then the "definition". Example:<br />;''''word'''':''''definition''''<br />You can also put the word and definition on separate lines if you wish. Example:<br />;''''word''''<br />:''''definition''''\r\n\r\n===Links===\r\n\r\nThere are two types of links, internal links and external links. Internal links can either use the title of the linked to page for the text of the link or alternate text. If you link to a page that does not exist yet (this is the easiest way to create pages) when you click on the link the page that comes up will have default/smart text for the page options such as title and such based on the link you followed to get there. You can use ''''''either'''''' short or full names for the links. Spaces are allowed in all areas ''''''except'''''' "Address" for an external link. A space defines the end of this type of link.\r\n\r\n;Internal - Link Text is equal to the Page Title - [.,.[''''Title''''].,.]: Makes a link that is called "Title" and links to page with name "Title". Example: [[Title]]\r\n;Internal - Link Text is ''''''not'''''' equal to the Page Title - [.,.[''''Title''''|''''Text''''].,.]: Makes a link that is called "Text" and links to page with name "Title". Example: [[Title|Text]]\r\n;External - [''''Address'''',.,''''Text'''']: Makes a link to "Address" that is named "Text". Example: [http://www.google.com/,.,Link,.,to,.,Google] - [http://www.google.com/ Link to Google]\r\n;External - Email: An email link is specified just like a regular link except the link should point to mailto:youremail@u.washington.edu. Example [mailto:asuwtech@u.washington.edu,.,Send,.,Me,.,an,.,Email] - [mailto:asuwtech@u.washington.edu Send Me an Email]\r\n\r\n===Images===\r\n\r\nImages are much like links in the way they are specified. I will begin with a sample tag and then explain further.\r\n\r\n[Image,.,''''ImageName'''',.,''''Align'''']\r\n\r\n;Image: Required. Specifies that this tag is referencing an image and not a external link.\r\n;ImageName: Required. The name of the image. Only used internally, can not contain spaces or punctuation or other non alpha-numerics. These are page specific so you can use the same name for images on different pages without worrying about conflicts. If you wish to use the same image multiple times on the same page just specify the same ImageName for each.\r\n;Align: Not Required. Should be all lowercase and one of the following five items: left, right, top, middle, bottom. Left and Right specify that the image should appear on the left and right side of the page with text wrapping around it. Top, Middle, and Bottom specify how the text aligns to the image. [http://www.uwec.edu/help/Dreamweaver04/img-align.htm Click here to see examples.]\r\n\r\n===Files===\r\n\r\nFiles are a hybrid between images and links in the way they are specified. I will begin with a sample tag and then explain further.\r\n\r\n[File,.,''''FileName'''',.,''''LinkText'''']\r\n\r\n;File: Required. Specifies that this tag is referencing an file and not a external link.\r\n;FileName: Required. The name of the file. Used internally, can not contain spaces or punctuation or other non alpha-numerics. These are page specific so you can use the same name for files on different pages without worrying about conflicts. If you wish to link to the same file multiple times on the same page just specify the same FileName for each.\r\n;LinkText: If unspecified, FileName will be used. This is just like ''''LinkText'''' for links. Can contain spaces, punctionation, anything really.\r\n\r\n===Site Options Explained===\r\n\r\nThese are explanations of the site option which you can edit when you are in admin mode. If you use any of the following items within the text they will be replaced by the current values.\r\n\r\n;<.,.SiteName> : The name that appears in the title bar. Current Value: ''''<SiteName>''''\r\n;<.,.PhysAddress> : Appears on the bottom. Current Value: ''''<PhysAddress>''''\r\n;<.,.PhoneNum> : Appears on the bottom. Current Value: ''''<PhoneNum>''''\r\n;<.,.FaxNum> : Appears on the bottom. Current Value: ''''<FaxNum>''''\r\n;<.,.EmailAddress> : Is linked to on the bottom. Current Value: ''''<EmailAddress>''''\r\n;<.,.MenuItems> : The pages that will appear in the menu along the top. Use the "Short Title" name of the page. Separated by commas, no spaces. Current Value: ''''<MenuItems>''''\r\n;<.,.SiteAdmin> : The UWNetID''s of the people allowed to edit the entire site. Use carefully. Separated by commas, no spaces. Current Value: ''''<SiteAdmin>''''\r\n;<.,.SiteRoot> : Don''t mess with this, it''s mainly if the site moves (as it will when it is made the default site). You may want it for replacements if you''re referring to the address of a page. Current Value: ''''<SiteRoot>''''\r\n;<.,.DefaultPage> : The main page. The page that is delivered if no specific page is requested. Current Value: ''''<DefaultPage>''''\r\n\r\n===Page Options Explained===\r\n\r\n;<.,.FullTitle> : The title of the page. Also displayed above the menu bar. Use caps, spaces, whatever. Must be unique. Current Value: ''''<FullTitle>''''\r\n;<.,.ShortTitle> : The ''internal'' title of the page. For addressing. Use all lower, no spaces. Must be unique. Current Value: ''''<ShortTitle>''''\r\n;<.,.PageAdmin> : Following the same procedure of Site Admin above, allows users to edit individual pages. Current Value: ''''<PageAdmin>''''\r\n;<.,.PageData> : The ''stuff'' on the page. It''s basically everything you see when you are editing a page.\r\n\r\n===Extremely Special Codes===\r\n\r\n;''''.''''.,.'''',''''.,.''''.'''' (period, comma, period): Used to display text, such as above, that would usually be replaced. Deletes the characters without replacing the resulting variable. For Example: <Full''''.''''.,.'''',''''.,.''''.''''Title> displays as <Full.,.Title>.\r\n;'''',''''.,.''''.''''.,.'''','''' (comma, period, comma): Same as above except instead of being deleted, replaces with a space. For Example: [Image'''',''''.,.''''.''''.,.'''',''''.,.''''ImageName''''] displays as [Image,.,''''ImageName''''].');

-- --------------------------------------------------------

-- 
-- Table structure for table `SiteInfo`
-- 

CREATE TABLE `SiteInfo` (
  `SiteID` smallint(5) unsigned NOT NULL auto_increment,
  `SiteName` tinytext NOT NULL,
  `PhysAddress` text NOT NULL,
  `PhoneNum` tinytext NOT NULL,
  `FaxNum` tinytext NOT NULL,
  `EmailAddress` tinytext NOT NULL,
  `MenuItems` text NOT NULL,
  `SiteAdmin` text NOT NULL,
  `SiteRoot` tinytext NOT NULL,
  `DefaultPage` tinytext NOT NULL,
  PRIMARY KEY  (`SiteID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ;

By default this code will make a howtoupdate page that will explain how to update the site. Additionally you will have to use phpMyAdmin, enter the database you just created, then go into the SiteInfo table. Once there perform the following task:

  1. Click Insert at the top to create a new record.
  2. Fill in the fields with the appropriate values explained below.
    • Leave SiteID blank, it is set to auto-index so the next available number will automatically be used.
    • SiteName should be the name of the site. Example: ASUW Arts and Entertainment
    • PhysAddress should be the physical address of the entity. Used in the template files, or not if not desired. Example: HUB 104C
    • PhoneNum should be the phone number of the entity. Used in the template files, or not if not desired. Example: 206.543.1780
    • FaxNum should be the fax number of the entity. Used in the template files, or not if not desired. Example: 206.685.4310
    • EmailAddress should be the contact address for this entity. Example: asuwtech@u.washington.edu.
    • MenuItems can be initially left blank. See the howtoupdate page on the site for how to update this.
    • SiteAdmin is the UWNetID of people who are allowed to administer this site. Example: asuwtech,asuweb
    • SiteRoot is the root folder that this program is stored in on the site. Example: If the address for the site is http://www.asuw.org/test/ then SiteRoot would be /test/. Generally, if this is the default for the site, SiteRoot can just be set to a /.
    • DefaultPage is the name of the page that comes up if no page is specified. I like to default this to howtoupdate, but this should generally be changed when the site goes live. Example: welcome.
  3. Make sure the option on the bottom reads: Save and then Go back to previous page.
  4. Click Go
  5. Note the SiteID of the entry you just created for future reference. This is generally the number 1 unless you have multiple sites in the same database.


Editing the config.php file

After the database has been created and configured you should then edit the config.php file. The following changes should be made.

mySQLPass
The password of the user specified in mySQLUser.
-host-
Exactly the same meaning as above, this should be the same value as above.
-DatabaseName-
Exactly the same meaning as above, this should be the same value as above.
mySQLUser
May not be the same name as -host-, although should be. Set to the same username as whoever owns this database.
defaultSite
May need to be changed if it is not a 1. Should be the same as the SiteID from above.
<?php
	$mySQLHost = 'localhost';
	$mySQLUser = '-host-';
	$mySQLPass = '';
	$mySQLDB = '-DatabaseName-';
	$mySQLExtMap = 'ExtMap';
	$mySQLSiteInfo = 'SiteInfo';
	$mySQLPageInfo = 'PageInfo';
	$imageDir = '/www/-host-/pageimages/';
	$fileDir = '/www/-host-/pagefiles/';
	$useNiceLinks = true;
	
	$pageTmpl = 'templates/page.tmpl';
	$menuItemTmpl = 'templates/menuitem.tmpl';
	$pageAdminTmpl = 'templates/pageadmin.tmpl';
	$genStaticTmpl = 'templates/genstatic.tmpl';
	$genAdminTmpl = 'templates/genadmin.tmpl';
	
	$defaultSite = '1';
?>

After you are done editing this file, as with any file that contains mySQL passwords, it should then be chmod 0600


The .htaccess Files

There are two .htaccess files, additionally the .htaccess files may be named htaccess so they are not hidden on your system. When put back on the server you should then mv htaccess .htaccess so that they are functional.

The following two replacements should be done.

-root-
The root folder of the site. Same as SiteRoot above. For example: If the site is at http://www.asuw.org/test/, root should be /test/
-host-
The host. Same as above. For example: If the site is at http://www.asuw.org/test/, host should be www

root .htaccess file

<IfModule mod_pubcookie.c>
    AuthType UWNetID
    PubcookieAppID boxAdmin
    PubcookieInactiveExpire -1
    require valid-user
</IfModule>

<IfModule mod_rewrite.c>
    Options SymLinksIfOwnerMatch
    RewriteEngine on
    RewriteBase    -root-
    
    RewriteCond    %{REQUEST_URI}   !/PubCookie\.reply
    RewriteCond    %{REQUEST_URI}   !/admin/
    RewriteCond    %{REQUEST_URI}   !.*\.css
    RewriteCond    %{REQUEST_URI}   !/images/.*
    RewriteCond    %{REQUEST_URI}   !/pageimages/.*
    RewriteCond    %{REQUEST_URI}   !/pagefiles/.*
    RewriteCond    %{REQUEST_URI}   !/index.php.*
    RewriteCond    %{REQUEST_URI}   !/$
    RewriteRule    (.*) index.php?a=$1 [L]
</IfModule>

admin .htaccess file

<IfModule mod_pubcookie.c>
	Redirect -root-admin/ http://-host-.asuw.org-root-
</IfModule>
<IfModule !mod_pubcookie.c>
	Redirect -root-admin/ https://-host-.asuw.org-root-
</IfModule>


Template Files Explained

The template files are stored, by default, in the templates directory. The names below correspond to the names of the templates specified by default in the config.php file, they may be different if they have been changed there. All template files can use any of the replacments specified in howtoupdate. See the example template files for help.

page.tmpl
This file contains the entire page layout. There a few replacements that are done that are not described on the howtoupdate page.
  • <PageDataMarkup> This is replaced by all the page data after is has been marked up.
  • <Menu> This is replaced by the template file menuitem.tmpl after all the items have been concatenated.
  • <EditData> This is replaced by the template files genadmin.tmpl or staticadmin.tmpl concatenated with pageadmin.tmpl if admin editing is possible. Otherwise it is just replaced with a NULL value.
menuitem.tmpl
A single menu item. As all the menu items are created each single menu item is concatenated on to the previous and then the whole thing is used to replace <Menu> in page.tmpl.
genadmin.tmpl
Allows editing of the general site variables. Must be specified in SiteAdmin to see this.
genstatic.tmpl
Should contain the general site variables sent back as hidden fields. Shown to those that are not specified in SiteAdmin but are specified in PageAdmin.
pageadmin.tmpl
Allows editing of the page variables. Must be specified in PageAdmin or SiteAdmin to see this.
Personal tools
Namespaces

Variants
Actions
Navigation
Tools