Skip to content

Commit bc09c64

Browse files
committed
adding the scripts
1 parent 203d621 commit bc09c64

File tree

5 files changed

+677
-0
lines changed

5 files changed

+677
-0
lines changed

cronscripts/updateDate.sh

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
#!/bin/bash
2+
# ------------------------------------------------------------
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
# ------------------------------------------------------------
20+
# This script is used to update the meeting time date on the
21+
# site.
22+
# Guidance from:
23+
# http://thelinuxtips.com/2012/12/06/finding-the-nth-particular-week-in-a-month-shell-script/
24+
25+
clear
26+
echo "Script to update meeting date. Assumes the meeting is\
27+
every 3rd Saturday of the month"
28+
29+
# constants
30+
DAY="1"
31+
FREQ="3"
32+
# ------------------------------------------------------------
33+
# functions
34+
USAGE()
35+
{
36+
echo "------------------------------------------------------"
37+
echo "USAGE :: updateDate YEAR MONTH WEBSITE"
38+
echo "For example: "
39+
echo "updateDate 2017 4 ~/public_html"
40+
echo "The above will return the date of the 3rd Saturday in May\
41+
and update all html pages accordingly"
42+
echo "Valid values for YEAR ( 2016 to 2050 )"
43+
echo "Valid values for MONTH ( 1 to 12 )"
44+
}
45+
46+
47+
YearCheck()
48+
{
49+
echo "$1" | grep -v "^[0-9]*$" >/dev/null 2>&1 && echo "Please enter the year" && USAGE
50+
if [[ ! "${1}" -le "2051" || "${1}" -eq "2016" ]]; then
51+
echo "Enter the correct Year [2017-2050]"
52+
USAGE
53+
fi
54+
}
55+
56+
MonthCheck()
57+
{
58+
echo "$1" | grep -v "^[0-9]*$" >/dev/null 2>&1 && echo "Please enter the month" && USAGE
59+
if [[ ! "${1}" -le "12" || "${1}" -eq "0" ]]; then
60+
echo "Enter the correct Month [1-12]"
61+
USAGE
62+
fi
63+
}
64+
65+
LastDigit()
66+
{
67+
lastD="${1: -1}"
68+
69+
if [[ $lastD == "1" ]]; then
70+
ordinalEnding="st"
71+
elif [[ $lastD == "2" ]]; then
72+
ordinalEnding="nd"
73+
elif [[ $lastD == "3" ]]; then
74+
ordinalEnding="rd"
75+
else
76+
ordinalEnding="th"
77+
fi
78+
79+
echo "$1$ordinalEnding"
80+
}
81+
82+
MonthStr()
83+
{
84+
if [[ $1 == "1" || $1 == "01" ]]; then
85+
mthStr="January"
86+
fi
87+
if [[ $1 == "2" || $1 == "02" ]]; then
88+
mthStr="February"
89+
fi
90+
if [[ $1 == "3" || $1 == "03" ]]; then
91+
mthStr="March"
92+
fi
93+
if [[ $1 == "4" || $1 == "04" ]]; then
94+
mthStr="April"
95+
fi
96+
if [[ $1 == "5" || $1 == "05" ]]; then
97+
mthStr="May"
98+
fi
99+
if [[ $1 == "6" || $1 == "06" ]]; then
100+
mthStr="June"
101+
fi
102+
if [[ $1 == "7" || $1 == "07" ]]; then
103+
mthStr="July"
104+
fi
105+
if [[ $1 == "8" || $1 == "08" ]]; then
106+
mthStr="August"
107+
fi
108+
if [[ $1 == "9" || $1 == "09" ]]; then
109+
mthStr="September"
110+
fi
111+
if [[ $1 == "10" ]]; then
112+
mthStr="October"
113+
fi
114+
if [[ $1 == "11" ]]; then
115+
mthStr="November"
116+
fi
117+
if [[ $1 == "12" ]]; then
118+
mthStr="December"
119+
fi
120+
echo "$mthStr"
121+
}
122+
# ------------------- end functions --------------------------
123+
124+
if [ "$#" -ne "3" ]; then
125+
USAGE
126+
else
127+
WEBSITE=$3
128+
YearCheck $1
129+
MonthCheck $2
130+
NY=$1
131+
NM=$2
132+
oldDay=`cal $2 $1| tail +5|cut -c19,20| sed -n 1p`
133+
oldMthStr=$(MonthStr ${NM})
134+
oldDate="$oldMthStr $(LastDigit ${oldDay}), $NY"
135+
oldDay=$((oldDay-1))
136+
137+
# get new date
138+
newMth=$((NM+1))
139+
newYr=$1
140+
141+
142+
if [[ $newMth == "13" ]]; then
143+
newYr=$((NY+1))
144+
newMth="1"
145+
fi
146+
147+
newDay=`cal $newMth $newYr| tail +5|cut -c19,20| sed -n 1p`
148+
newMthStr=$(MonthStr ${newMth})
149+
newDate="$newMthStr $(LastDigit ${newDay}), $newYr"
150+
151+
# change all the dates
152+
$PWD/updatePages.sh $WEBSITE "${oldDate}" "${newDate}"
153+
154+
# add the updated files to GitHub
155+
cd $WEBSITE
156+
git add *
157+
git commit -m 'updated with new meeting date'
158+
git push origin
159+
160+
echo "New Date: $newDate Old Date: $oldDate"
161+
fi

cronscripts/updatePages.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
# ------------------------------------------------------------
3+
# Licensed to the Apache Software Foundation (ASF) under one
4+
# or more contributor license agreements. See the NOTICE file
5+
# distributed with this work for additional information
6+
# regarding copyright ownership. The ASF licenses this file
7+
# to you under the Apache License, Version 2.0 (the
8+
# "License"); you may not use this file except in compliance
9+
# with the License. You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing,
14+
# software distributed under the License is distributed on an
15+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
# KIND, either express or implied. See the License for the
17+
# specific language governing permissions and limitations
18+
# under the License.
19+
# ------------------------------------------------------------
20+
# This script is used to change the meeting time date on the
21+
# site
22+
23+
clear
24+
echo "Script to update meeting date."
25+
echo $1 $2 $3
26+
27+
if [ "$#" -ne "3" ]; then
28+
echo "USAGE :: updatePages path-to-pages oldDate newDate"
29+
echo "Dates should be in the format - Month DDth, YYYY"
30+
echo "For example: "
31+
echo "updateDate /home/public_html 'March 18th, 2017' 'April 22nd, 2017'"
32+
echo "The above will return update the date on all html pages accordingly."
33+
echo "Please rerun script with correct arguments."
34+
exit 0
35+
else
36+
noFiles=`grep -rl "$2" $1`
37+
38+
if [[ -z $noFiles ]]; then
39+
echo "No files with the date $2 were found. Exiting!"
40+
exit 1
41+
else
42+
grep -rl "$2" $1 | xargs sed -i '' -e "s/${2}/${3}/g"
43+
echo "Date changes complete!"
44+
fi
45+
fi

website-checks/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
Test scripts to check htmls
2+
===========================
3+
4+
Required:
5+
Python 2.7+
6+
PhantomJS
7+
8+
Python libs
9+
* selenium
10+
* pyvirtualdisplay
11+
* tika
12+
* reppy
13+
* nltk
14+
15+
These checks cover:
16+
* check for robots.txt file
17+
* check for alt TEXT in img tags
18+
* check for PDF text and download links where PDF links are given
19+
* simple spell checker
20+
* check that images linked to exisit
21+
22+
23+
USAGE of htmlPageChecker
24+
`python htmlPageChecker -h`
25+
To check only pages: run `python htmlPageChecker.py -p <[htmlPage]>`
26+
e.g. `python htmlPageChecker.py -p ../cflbajans/index.html`
27+
`python htmlPageChecker.py -p '../cflbajans/index.html, ../cflbajans/index.html'`
28+
`python htmlPageChecker.py -p ../cflbajans/*.html`
29+
To check the full website folder: run `python htmlPageChecker.py -s <site-dir>`
30+
e.g. `python htmlPageChecker.py -s ../cflbajans`
31+
To run checks on the website (remote): run `python htmlPageChecker.py -w <website domain>`
32+
e.g. `python htmlPageChecker.py -w www.cflbajans.com`
33+
34+
Note that you can add or remove words in specialDict.txt for spellchecking. Be sure the words are all lowercase.
35+
36+
** I'm addressing an issue here. If you want run on site on the web, please use Firefox. For local files, use PhantomJS.
37+
Todo this change self.driver = webdriver.PhantomJS() to self.driver = webdriver.Firefox() and vice versa
38+
39+
TODOS
40+
=====
41+
* the browser issue
42+
* better spell checking
43+
* increase num of tests

0 commit comments

Comments
 (0)