Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
freedombone
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Context Sensitive Group
freedombone
Commits
a6f77d84
Commit
a6f77d84
authored
8 years ago
by
Bob Mottram
Browse files
Options
Downloads
Patches
Plain Diff
Pelican interactive configuration
parent
1b9d528e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/freedombone-app-pelican
+206
-34
206 additions, 34 deletions
src/freedombone-app-pelican
with
206 additions
and
34 deletions
src/freedombone-app-pelican
+
206
−
34
View file @
a6f77d84
...
...
@@ -36,18 +36,191 @@ SHOW_ON_ABOUT=0
PELICAN_BLOG_DOMAIN
=
PELICAN_BLOG_CODE
=
STATIC_BLOG_INSTALL_DIR
=
/etc/staticblog
PELICAN_THEMES_REPO
=
"https://github.com/getpelican/pelican-themes"
PELICAN_PLUGINS_REPO
=
"https://github.com/getpelican/pelican-plugins"
DEFAULT_BLOG_TITLE
=
$"Freedombone Blog"
PELICAN_BLOG_INSTALL_DIR
=
/etc/blog
CURRENT_BLOG_INDEX
=
$PELICAN_BLOG_INSTALL_DIR
/.blog-index
PELICAN_PELICAN_BLOG_INSTALL_DIR
=
/var/www/
$PELICAN_BLOG_DOMAIN
/htdocs
pelican_variables
=(
MY_USERNAME
ONION_ONLY
PELICAN_BLOG_DOMAIN
PELICAN_BLOG_CODE
)
function
pelican_regenerate_blog
{
clear
echo
''
echo
$'Regenerating blog...'
cd
$PELICAN_BLOG_INSTALL_DIR
make html
}
function
pelican_new_blog
{
DATESTR
=
$(
date
"+%Y-%m-%d %H:%M:%S"
)
echo
$'Title: Blog Post Title'
>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$"Date:
${
DATESTR
}
"
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$"Author:
$(
toxid
--showuser
)
"
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$'Category: default'
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$'Tags: blog, tag'
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
''
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$'Add your text here'
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
''
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
-n
$'To include an image copy it into the /etc/blog/content/images directory, '
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$'then link to it with:'
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
''
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
$''
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
echo
''
>>
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
editor
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
if
grep
-q
$"Add your text here"
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
;
then
return
fi
if
grep
-q
$"Blog Post Title"
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
;
then
return
fi
if
[
!
-f
$CURRENT_BLOG_INDEX
]
;
then
echo
'0'
>
$CURRENT_BLOG_INDEX
fi
# move to the content directory
CURRENT_INDEX
=
$(
cat
$CURRENT_BLOG_INDEX
)
mv
$PELICAN_BLOG_INSTALL_DIR
/.new-blog-entry
$BLOG_CONTENT_PATH
/
${
CURRENT_INDEX
}
_post.md
# increment the index
CURRENT_INDEX
=
$((
CURRENT_INDEX
+
1
))
echo
"
$CURRENT_INDEX
"
>
$CURRENT_BLOG_INDEX
pelican_regenerate_blog
}
function
pelican_edit_blog
{
if
[
!
-f
$CURRENT_BLOG_INDEX
]
;
then
return
fi
CURRENT_INDEX
=
$(
cat
$CURRENT_BLOG_INDEX
)
PREVIOUS_INDEX
=
$((
CURRENT_INDEX
-
1
))
LAST_BLOG_ENTRY
=
$BLOG_CONTENT_PATH
/
${
PREVIOUS_INDEX
}
_post.md
if
[
!
-f
$LAST_BLOG_ENTRY
]
;
then
return
fi
editor
$LAST_BLOG_ENTRY
regenerate_blog
}
function
pelican_delete_blog
{
if
[
!
-f
$CURRENT_BLOG_INDEX
]
;
then
return
fi
CURRENT_INDEX
=
$(
cat
$CURRENT_BLOG_INDEX
)
PREVIOUS_INDEX
=
$((
CURRENT_INDEX
-
1
))
LAST_BLOG_ENTRY
=
$BLOG_CONTENT_PATH
/
${
PREVIOUS_INDEX
}
_post.md
if
[
!
-f
$LAST_BLOG_ENTRY
]
;
then
return
fi
dialog
--title
$"Delete the previous blog entry"
\
--backtitle
$"Freedombone Mesh"
\
--defaultno
\
--yesno
$"
\n
Are you sure that you wish to delete the previous blog entry?"
8 60
sel
=
$?
case
$sel
in
0
)
rm
$LAST_BLOG_ENTRY
if
[
$CURRENT_INDEX
-gt
0
]
;
then
CURRENT_INDEX
=
$PREVIOUS_INDEX
echo
"
$CURRENT_INDEX
"
>
$CURRENT_BLOG_INDEX
else
rm
-f
$CURRENT_BLOG_INDEX
fi
pelican_regenerate_blog
;;
esac
}
function
pelican_change_theme
{
THEMES
=()
for
d
in
$PELICAN_BLOG_INSTALL_DIR
/themes/
*
/
;
do
THEME_NAME
=
$(
echo
"
$d
"
|
awk
-F
'/'
'{print $6}'
)
THEMES+
=(
"
$THEME_NAME
"
)
done
themelist
=
""
n
=
1
theme_index
=
0
curr_theme_index
=
if
[
-f
$PELICAN_BLOG_INSTALL_DIR
/.blog-theme-index
]
;
then
curr_theme_index
=
$(
cat
$PELICAN_BLOG_INSTALL_DIR
/.blog-theme-index
)
fi
for
a
in
"
${
THEMES
[@]
}
"
do
is_selected
=
'off'
if
[
$curr_theme_index
]
;
then
if
[
$n
-eq
$curr_theme_index
]
;
then
is_selected
=
'on'
fi
else
if
[[
"
$a
"
==
'nice-blog'
]]
;
then
is_selected
=
'on'
fi
fi
themelist
=
"
$themelist
$n
$a
$is_selected
"
n
=
$[
n+1]
theme_index
=
$[
theme_index+1]
done
data
=
$(
tempfile 2>/dev/null
)
trap
"rm -f
$data
"
0 1 2 5 15
dialog
--backtitle
$"Freedombone Mesh"
\
--title
$"Select Blog Theme"
\
--radiolist
$'Choose:'
\
80 40 20
$themelist
2>
$data
sel
=
$?
case
$sel
in
1
)
exit
1
;;
255
)
exit
1
;;
esac
CHOSEN_THEME_INDEX
=
$(
cat
$data
)
echo
"
$CHOSEN_THEME_INDEX
"
>
$PELICAN_BLOG_INSTALL_DIR
/.blog-theme-index
CHOSEN_THEME_INDEX
=
$((
CHOSEN_THEME_INDEX
-
1
))
CHOSEN_THEME
=
${
THEMES
[
$CHOSEN_THEME_INDEX
]
}
if
grep
-q
"THEME="
$PELICAN_BLOG_INSTALL_DIR
/pelicanconf.py
;
then
sed
-i
"s|THEME=.*|THEME='themes/
${
CHOSEN_THEME
}
'|g"
$PELICAN_BLOG_INSTALL_DIR
/pelicanconf.py
else
echo
"THEME='themes/
${
CHOSEN_THEME
}
'"
>>
$PELICAN_BLOG_INSTALL_DIR
/pelicanconf.py
fi
pelican_regenerate_blog
}
function
configure_interactive_pelican
{
echo
-n
''
data
=
$(
tempfile 2>/dev/null
)
trap
"rm -f
$data
"
0 1 2 5 15
dialog
--backtitle
$"Freedombone Configuration"
\
--title
$"Pelican Blogging"
\
--radiolist
$"Choose an operation:"
18 50 11
\
1
$"New blog entry"
off
\
2
$"Edit the previous blog entry"
off
\
3
$"Delete the previous blog entry"
off
\
4
$"Change theme"
off
\
5
$"Exit"
off 2>
$data
sel
=
$?
case
$sel
in
1
)
exit
1
;;
255
)
exit
1
;;
esac
case
$(
cat
$data
)
in
1
)
pelican_new_blog
;;
2
)
pelican_edit_blog
;;
3
)
pelican_delete_blog
;;
4
)
pelican_change_theme
;;
5
)
break
;;
esac
}
function
install_interactive_pelican
{
...
...
@@ -252,7 +425,7 @@ function create_pelican_makefile {
echo
''
>>
$STATIC_BLOG_FILE
echo
'BASEDIR=$(CURDIR)'
>>
$STATIC_BLOG_FILE
echo
'INPUTDIR=$(BASEDIR)/content'
>>
$STATIC_BLOG_FILE
echo
"OUTPUTDIR=
$
STATIC
_BLOG_PATH
"
>>
$STATIC_BLOG_FILE
echo
"OUTPUTDIR=
$
PELICAN
_BLOG_PATH
"
>>
$STATIC_BLOG_FILE
echo
'CONFFILE=$(BASEDIR)/pelicanconf.py'
>>
$STATIC_BLOG_FILE
echo
'PUBLISHCONF=$(BASEDIR)/publishconf.py'
>>
$STATIC_BLOG_FILE
echo
''
>>
$STATIC_BLOG_FILE
...
...
@@ -413,32 +586,32 @@ function mesh_install_pelican {
chroot
"
$rootdir
"
pip
install
typogrify
chroot
"
$rootdir
"
pip
install
pelican
STATIC
_BLOG_INSTALL_DIR
=
/home/
$MY_USERNAME
/CreateBlog
STATIC
_BLOG_PATH
=
/home/
$MY_USERNAME
/Public/Blog
PELICAN
_BLOG_INSTALL_DIR
=
/home/
$MY_USERNAME
/CreateBlog
PELICAN
_BLOG_PATH
=
/home/
$MY_USERNAME
/Public/Blog
if
[
!
-d
$rootdir$
STATIC
_BLOG_INSTALL_DIR
]
;
then
mkdir
-p
$rootdir$
STATIC
_BLOG_INSTALL_DIR
if
[
!
-d
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
]
;
then
mkdir
-p
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
fi
if
[
!
-d
$rootdir$
STATIC
_BLOG_PATH
]
;
then
mkdir
-p
$rootdir$
STATIC
_BLOG_PATH
if
[
!
-d
$rootdir$
PELICAN
_BLOG_PATH
]
;
then
mkdir
-p
$rootdir$
PELICAN
_BLOG_PATH
fi
if
[
!
-d
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/content/images
]
;
then
mkdir
-p
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/content/images
if
[
!
-d
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/content/images
]
;
then
mkdir
-p
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/content/images
fi
create_pelican_conf
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/pelicanconf.py
create_pelican_makefile
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/Makefile
create_pelican_publish_conf
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/publishconf.py
create_pelican_conf
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/pelicanconf.py
create_pelican_makefile
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/Makefile
create_pelican_publish_conf
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/publishconf.py
mkdir
-p
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/themes
cd
$rootdir$
STATIC
_BLOG_INSTALL_DIR
/themes
mkdir
-p
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/themes
cd
$rootdir$
PELICAN
_BLOG_INSTALL_DIR
/themes
pelican_themes
#git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$
STATIC
_BLOG_INSTALL_DIR/plugins
#git clone --recursive $PELICAN_PLUGINS_REPO $rootdir$
PELICAN
_BLOG_INSTALL_DIR/plugins
chroot
"
$rootdir
"
chown
-R
$MY_USERNAME
:
$MY_USERNAME
$
STATIC
_BLOG_INSTALL_DIR
chroot
"
$rootdir
"
chown
-R
$MY_USERNAME
:
$MY_USERNAME
$
PELICAN
_BLOG_INSTALL_DIR
chroot
"
$rootdir
"
chown
-R
$MY_USERNAME
:
$MY_USERNAME
/home/
$MY_USERNAME
/Public
}
...
...
@@ -454,33 +627,32 @@ function install_pelican {
pip
install
typogrify
pip
install
pelican
STATIC_BLOG_INSTALL_DIR
=
/etc/blog
STATIC_BLOG_PATH
=
/var/www/
$PELICAN_BLOG_DOMAIN
/htdocs
PELICAN_BLOG_PATH
=
/var/www/
$PELICAN_BLOG_DOMAIN
/htdocs
if
[
!
-d
$
STATIC
_BLOG_INSTALL_DIR
]
;
then
mkdir
-p
$
STATIC
_BLOG_INSTALL_DIR
if
[
!
-d
$
PELICAN
_BLOG_INSTALL_DIR
]
;
then
mkdir
-p
$
PELICAN
_BLOG_INSTALL_DIR
fi
if
[
!
-d
$
STATIC
_BLOG_PATH
]
;
then
mkdir
-p
$
STATIC
_BLOG_PATH
if
[
!
-d
$
PELICAN
_BLOG_PATH
]
;
then
mkdir
-p
$
PELICAN
_BLOG_PATH
fi
if
[
!
-d
$
STATIC
_BLOG_INSTALL_DIR
/content
]
;
then
mkdir
-p
$
STATIC
_BLOG_INSTALL_DIR
/content
if
[
!
-d
$
PELICAN
_BLOG_INSTALL_DIR
/content
]
;
then
mkdir
-p
$
PELICAN
_BLOG_INSTALL_DIR
/content
fi
create_pelican_conf
$
STATIC
_BLOG_INSTALL_DIR
/pelicanconf.py
create_pelican_makefile
$
STATIC
_BLOG_INSTALL_DIR
/Makefile
create_pelican_publish_conf
$
STATIC
_BLOG_INSTALL_DIR
/publishconf.py
create_pelican_conf
$
PELICAN
_BLOG_INSTALL_DIR
/pelicanconf.py
create_pelican_makefile
$
PELICAN
_BLOG_INSTALL_DIR
/Makefile
create_pelican_publish_conf
$
PELICAN
_BLOG_INSTALL_DIR
/publishconf.py
mkdir
-p
$PELICAN_THEMES_REPO
$
STATIC
_BLOG_INSTALL_DIR
/themes
cd
$PELICAN_THEMES_REPO
$
STATIC
_BLOG_INSTALL_DIR
/themes
mkdir
-p
$PELICAN_THEMES_REPO
$
PELICAN
_BLOG_INSTALL_DIR
/themes
cd
$PELICAN_THEMES_REPO
$
PELICAN
_BLOG_INSTALL_DIR
/themes
pelican_themes
#git clone --recursive $PELICAN_PLUGINS_REPO $
STATIC
_BLOG_INSTALL_DIR/plugins
#git clone --recursive $PELICAN_PLUGINS_REPO $
PELICAN
_BLOG_INSTALL_DIR/plugins
chown
-R
$MY_USERNAME
:
$MY_USERNAME
$
STATIC
_BLOG_INSTALL_DIR
chown
-R
www-data:www-data
$
STATIC
_BLOG_PATH
chown
-R
$MY_USERNAME
:
$MY_USERNAME
$
PELICAN
_BLOG_INSTALL_DIR
chown
-R
www-data:www-data
$
PELICAN
_BLOG_PATH
APP_INSTALLED
=
1
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment