description | Basic PHP web framework for static websites |
last change | Tue, 26 Dec 2017 09:50:38 +0000 (10:50 +0100) |
URL | [public ] git://auder.net/sview.git |
[private] git@auder.net:sview.git |
It is inspired by a similar framework written by Arnór Heiðar Sigurðsson. In the same spirit but more advanced and more complete, see also nanoc - in Ruby.
sview is designed to organize essentially static websites. It does not offer the features you would expect from a complete MVC framework - actually, it has only the “V” part. If you want a more demanding dynamic website, consider using an appropriate tool, Symfony for example.
The file sample-website.tar.xz provides a basic but full website example. Alternatively, here are some details about sview usage.
In the following, I assume your website is located under http[s]://domain/topic/ and is named “website” (adapt to your case). For example, in https://github.com/blog/ domain = github.com and topic = blog.
Get the source code either with git clone
command or using a zip archive.
Copy all folder contents in the website/ folder :
website/
a/
f/
site/
.htaccess
common.php
defaults.php
index.php
s.php</pre>
Now (online), in the .htaccess file, change the line RewriteBase /
to RewriteBase /topic
.
Edit the file defaults.php with
<link rel="stylesheet" href="http://cran.r-project.org/R.css"/>
.
We will see later how to refer to local stylesheets (under a/css).Each variable name is prepended with “b_” to avoid potential conflicts with your own variables.
Complete
You can also change the <meta> tags if needed.
The welcome page. You can choose a title ($s_title) or use the default one (by not specifying anything). Stylesheets and javascripts can be customized, …etc. Any default variable can be used to define a specific variable (prepended with “s_”).
Customize it; it is probably viewed more often than you think ;-)
All pages are under site/ folder, and you can nest them in any directory tree.
Hint : if you don’t want to load the main template, just end any site file with a PHP exit
directive.
Now we will see how to access pages and resources (images, CSS, files, javascript).
The page at physical location site/some_folder/mypage.php is viewed in the web browser at the URL http[s]://domain/topic/website/some_folder/mypage (thanks to URL rewriting defined in the .htaccess file).
Any page can be linked internally using the r()
PHP function (‘r’ for “resource”), like in
the following : <a href="<?php echo r('some_folder/mypage'); >>
. This function determines
the nesting level and output the appropriate path.
A CSS style sheet : its path is given by the following PHP function call
r('a/css/name_of_the_file.css')
from within any site file (assuming you place all CSS files
under a/css/. They may be inside a nested folder structure).
An image : same as above, with r('a/img/name_of_the_image.xxx')
.
A javascript file : same as above, with r('a/js/name_of_the_file.js')
.
Just use a regular link pointing to r('dl/?f=name_of_the_file.xxx')
, anywhere you want.
Just add pages under site/ folder, and potential resources and files under a/ and f/. All other files will not change a lot.
2017-12-26 | Benjamin Auder | style sheet --> stylesheet master | commit | commitdiff | tree | snapshot |
2016-07-22 | Benjamin Auder | convert icelandic accents to HTML (TODO: fix gitweb...) | commit | commitdiff | tree | snapshot |
2016-07-22 | Benjamin Auder | fix lists in readme | commit | commitdiff | tree | snapshot |
2016-07-22 | Benjamin Auder | after merging | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | fix typo | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | split README (README.html + HOWTO.html) | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | fix README.html | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | fix README.html | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | fix README.html | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | merge README.md and HOWTO.md. Translate to html | commit | commitdiff | tree | snapshot |
2015-02-05 | Benjamin Auder | first commit after cleaning | commit | commitdiff | tree | snapshot |
7 years ago | master | shortlog | log | tree |