~code.norl.info/cmb/devel

« back to all changes in this revision

Viewing changes to cmb.sh

  • Committer: waffel
  • Date: 2010-03-27 18:21:37 UTC
  • Revision ID: waffel@phun-20100327182137-eoqx6l0aaz8a3qj1
Corrected Initial Release. Sorry...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
# +----------------------------------------------------------------------------+
4
 
# |                       Content Management Bash v0.1                         |
5
 
# +----------------------------------------------------------------------------+
6
 
# | The CMB is licensed under GPLv3 - Copyright (C) 2010 Flavio Waechter       |
7
 
# |                                                                            |
8
 
# | This program is free software; you can redistribute it and/or modify it    |
9
 
# | under the terms of the GNU General Public License as published by the      |
10
 
# | Free Software Foundation; either version 3 of the License, or              |
11
 
# | (at your option) any later version.                                        |
12
 
# |                                                                            |
13
 
# | This program is distributed in the hope that it will be useful,            |
14
 
# | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
15
 
# | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.                       |
16
 
# | See the GNU General Public License for more details.                       |
17
 
# |                                                                            |
18
 
# | You should have received a copy of the GNU General Public License along    |
19
 
# | with this program; if not, see <http://www.gnu.org/licenses/>.             |
20
 
# +----------------------------------------------------------------------------+
21
 
 
22
 
 
23
 
readTemplate() {
24
 
        TEMPLATEFILES=$(ls -1 template)
25
 
}
26
 
 
27
 
readContent() {
28
 
        CONTENTFILES=$(ls -1 content)
29
 
}
30
 
 
31
 
createNavigation() {
32
 
        echo -ne "</div>" > template/navigation.tpl
33
 
 
34
 
        echo -ne "<div id=\"navigation\">" >> template/navigation.tpl
35
 
        echo -ne "<ul>" >> template/navigation.tpl
36
 
                
37
 
        for FILE in content/*
38
 
        do
39
 
                SOURCEFILENAME=$(echo $FILE | cut -d "/" -f 2)
40
 
                
41
 
                echo -ne "<li><a href=\"$SOURCEFILENAME.html\">$SOURCEFILENAME</a></li>" >> template/navigation.tpl
42
 
        done
43
 
        
44
 
        echo -ne "</ul>" >> template/navigation.tpl
45
 
        echo -ne "</div>" >> template/navigation.tpl
46
 
}
47
 
 
48
 
buildIndex() {
49
 
        TEMPLATEHEADER=$(cat template/header.tpl)
50
 
        TEMPLATENAVIGATION=$(cat template/navigation.tpl)
51
 
        TEMPLATEFOOTER=$(cat template/footer.tpl)
52
 
 
53
 
        for FILE in content/*
54
 
        do
55
 
                CONTENTCONTENT=$(cat $FILE)
56
 
                SOURCEFILENAME=$(echo $FILE | cut -d "/" -f 2)
57
 
                
58
 
                DESTFILENAME=$(echo web/$SOURCEFILENAME.html)
59
 
                echo $DESTFILENAME
60
 
 
61
 
                echo "$TEMPLATEHEADER" > $DESTFILENAME
62
 
                echo "$CONTENTCONTENT" >> $DESTFILENAME
63
 
                echo "$TEMPLATENAVIGATION" >> $DESTFILENAME
64
 
                echo "$TEMPLATEFOOTER" >> $DESTFILENAME
65
 
        done
66
 
}
67
 
 
68
 
readTemplate
69
 
readContent
70
 
createNavigation
71
 
 
72
 
buildIndex