From 5e216478a3bedce5e2598825f873e66c3e229d22 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Wed, 22 Jul 2020 18:45:38 +0200
Subject: [PATCH 01/10] fix footer text margin style
---
kit/css/footer.css | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/kit/css/footer.css b/kit/css/footer.css
index 4a56020..05526e0 100644
--- a/kit/css/footer.css
+++ b/kit/css/footer.css
@@ -181,6 +181,9 @@
font-size: 1.55556rem;
line-height: 1.77778rem;
}
+ .footer-bottom .content-wrap {
+ padding: 0;
+ }
}
@media (max-width: 1024px) {
@@ -307,6 +310,8 @@
display: flex;
justify-content: space-between;
align-items: center;
+ overflow-wrap: break-word;
+ flex-wrap: wrap;
}
.footer-bottom .content-wrap ul {
@@ -340,9 +345,3 @@
.footer-bottom .content-wrap .copyright {
margin-top: 0px;
}
-
-.footer-bottom .content-wrap {
- overflow-wrap: break-word;
- flex-wrap: wrap;
- padding: 0;
-}
From dae32307ff446e8a6ce9d9e660ea22b5683d82b9 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Wed, 22 Jul 2020 18:52:52 +0200
Subject: [PATCH 02/10] fix wrong search results on special chars
---
kit/functions.php | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/kit/functions.php b/kit/functions.php
index 5893f05..592df0f 100644
--- a/kit/functions.php
+++ b/kit/functions.php
@@ -431,32 +431,14 @@ add_action( 'widgets_init', 'kit_widgets_init' );
# Highlight query in search results
-function highlight_search_term_placeholders() {
- static $iter = 0;
- $ret = "|##{$iter}##|";
- $iter++;
- return $ret;
-}
-function highlight_search_term_cb() {
- static $iter = 0;
- $ret = "##{$iter}##";
- $iter++;
- return $ret;
-}
-function highlight_search_term($text){
- if(is_search() && !is_admin()){
- $keys = implode('|', explode(' ', get_search_query()));
- $pattern = '/<[^>].*?>/i';
- preg_match_all($pattern,$text,$matches);
- $placeholders = array();
- foreach ($matches[0] as $v) {
- $placeholders[] = highlight_search_term_placeholders();
+function highlight_results($text) {
+ if (is_search() && !is_admin()) {
+ $sr = get_query_var('s');
+ $keys = explode(' ', $sr);
+ $keys = array_filter($keys);
+ $text = preg_replace('/('.implode('|', $keys) .')/iu', '\0', $text);
}
- $text = preg_replace_callback($pattern,'highlight_search_term_cb',$text);
- $pattern2 = '/(' . $keys .')/iu';
- $text = preg_replace($pattern2, ' \1 ', $text);
- $text = preg_replace($placeholders,$matches[0],$text);
- }
- return $text;
+ return $text;
}
-add_filter('the_excerpt', 'highlight_search_term');
+
+add_filter('the_excerpt', 'highlight_results');
From ef9644c8d70f9229a69de5672b6732a8553f90a9 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Wed, 22 Jul 2020 19:48:19 +0200
Subject: [PATCH 03/10] fix search results length and formatting
---
kit/functions.php | 26 +++++++++++++++++---------
kit/search.php | 3 ++-
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/kit/functions.php b/kit/functions.php
index 592df0f..efc50aa 100644
--- a/kit/functions.php
+++ b/kit/functions.php
@@ -431,14 +431,22 @@ add_action( 'widgets_init', 'kit_widgets_init' );
# Highlight query in search results
-function highlight_results($text) {
- if (is_search() && !is_admin()) {
- $sr = get_query_var('s');
- $keys = explode(' ', $sr);
- $keys = array_filter($keys);
- $text = preg_replace('/('.implode('|', $keys) .')/iu', '\0', $text);
- }
- return $text;
+function limit_text($text, $limit) {
+ if (str_word_count($text, 0) > $limit) {
+ $words = str_word_count($text, 2);
+ $pos = array_keys($words);
+ $text = substr($text, 0, $pos[$limit]);
+ }
+ return $text;
}
-add_filter('the_excerpt', 'highlight_results');
+function search_excerpt_highlight() {
+
+ $excerpt = wp_strip_all_tags( get_the_content() );
+ $excerpt = limit_text( $excerpt, 32);
+
+ $keys = implode('|', explode(' ', get_search_query()));
+ $excerpt = preg_replace('/(' . $keys .')/iu', '\0', $excerpt);
+
+ echo '... ' . $excerpt . ' ...
';
+}
diff --git a/kit/search.php b/kit/search.php
index d21438b..f015a13 100644
--- a/kit/search.php
+++ b/kit/search.php
@@ -77,7 +77,8 @@ get_header();
-
+
+
Weiterlesen
From 9423a7bff00d498b159d8df8fd282d080e583403 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Thu, 23 Jul 2020 09:59:06 +0200
Subject: [PATCH 04/10] highlight query in search result more precisley
---
kit/functions.php | 60 +++++++++++++++++++++++++++++++++++++----------
1 file changed, 48 insertions(+), 12 deletions(-)
diff --git a/kit/functions.php b/kit/functions.php
index efc50aa..7ba51a9 100644
--- a/kit/functions.php
+++ b/kit/functions.php
@@ -431,22 +431,58 @@ add_action( 'widgets_init', 'kit_widgets_init' );
# Highlight query in search results
-function limit_text($text, $limit) {
- if (str_word_count($text, 0) > $limit) {
- $words = str_word_count($text, 2);
- $pos = array_keys($words);
- $text = substr($text, 0, $pos[$limit]);
+function generate_excerpt($text, $query, $length) {
+
+ $words = explode(' ', $text);
+ $total_words = count($words);
+
+ if ($total_words > $length) {
+
+ $queryLow = array_map('strtolower', $query);
+ $wordsLow = array_map('strtolower', $words);
+
+ for ($i=0; $i <= $total_words; $i++) {
+
+ foreach ($queryLow as $queryItem) {
+
+ if (preg_match("/\b$queryItem\b/", $wordsLow[$i])) {
+ $posFound = $i;
+ break;
+ }
+ }
+
+ if ($posFound) {
+ break;
+ }
+ }
+
+ if ($i > ($length+($length/2))) {
+ $i = $i - ($length/2);
+ } else {
+ $i = 0;
+ }
+
+ }
+
+ $cutword = array_splice($words,$i,$length);
+ $excerpt = implode(' ', $cutword);
+
+ $keys = implode('|', $query);
+ $excerpt = preg_replace('/(' . $keys .')/iu', '\0', $excerpt);
+ $excerptRet = '';
+ if ($i !== 0) {
+ $excerptRet .= '... ';
}
- return $text;
+ $excerptRet .= $excerpt . ' ...
';
+
+ return $excerptRet;
}
function search_excerpt_highlight() {
- $excerpt = wp_strip_all_tags( get_the_content() );
- $excerpt = limit_text( $excerpt, 32);
+ $length = 32;
+ $text = wp_strip_all_tags( get_the_content() );
+ $query = explode(' ', get_search_query());
- $keys = implode('|', explode(' ', get_search_query()));
- $excerpt = preg_replace('/(' . $keys .')/iu', '\0', $excerpt);
-
- echo '... ' . $excerpt . ' ...
';
+ echo generate_excerpt($text, $query, $length);
}
From c1ca62ea2e4379225f168b6dbda98ead6c41785b Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Fri, 24 Jul 2020 13:32:51 +0200
Subject: [PATCH 05/10] check if search results exists
---
kit/functions.php | 2 ++
kit/search.php | 31 +++++++++++++++++++++----------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/kit/functions.php b/kit/functions.php
index 7ba51a9..259cfaa 100644
--- a/kit/functions.php
+++ b/kit/functions.php
@@ -484,5 +484,7 @@ function search_excerpt_highlight() {
$text = wp_strip_all_tags( get_the_content() );
$query = explode(' ', get_search_query());
+ print_r($query);
+
echo generate_excerpt($text, $query, $length);
}
diff --git a/kit/search.php b/kit/search.php
index f015a13..43f6394 100644
--- a/kit/search.php
+++ b/kit/search.php
@@ -44,16 +44,27 @@ get_header();
post_count);
- _e("Showing results", 'kit');
- echo " ";
- printf( esc_html__( '%d to %d', 'kit' ), $post_count_start, $post_count_end );
- echo " ";
- _e("from total results", 'kit');
- echo " " . $wp_query->found_posts. "";
+
+ # Check if search results exists
+ if ($wp_query->found_posts) {
+
+ $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
+ $post_count_start = (($paged -1) * 10) + 1;
+ $post_count_end = ((($paged -1) * 10) + $wp_query->post_count);
+ _e("Showing results", 'kit');
+ echo " ";
+ printf( esc_html__( '%d to %d', 'kit' ), $post_count_start, $post_count_end );
+ echo " ";
+ _e("from total results", 'kit');
+ echo " " . $wp_query->found_posts. "";
+
+ } else {
+
+ echo "
";
+ _e("No results found", 'kit');
+ echo ".
";
+
+ }
?>
From aad50bf2396a727c00095d7bc5625be189ca1739 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Fri, 24 Jul 2020 14:21:55 +0200
Subject: [PATCH 06/10] fix search results containing double quotes
---
kit/functions.php | 22 ++++++++++++++++------
1 file changed, 16 insertions(+), 6 deletions(-)
diff --git a/kit/functions.php b/kit/functions.php
index 259cfaa..7000ac5 100644
--- a/kit/functions.php
+++ b/kit/functions.php
@@ -476,15 +476,25 @@ function generate_excerpt($text, $query, $length) {
$excerptRet .= $excerpt . ' ...';
return $excerptRet;
+
}
function search_excerpt_highlight() {
- $length = 32;
- $text = wp_strip_all_tags( get_the_content() );
- $query = explode(' ', get_search_query());
+ # Length in word count
+ $excerptLength = 32;
+
+ $text = wp_strip_all_tags( get_the_content() );
+
+ # Filter double quotes from query. They will
+ # work on the results side but won't help with
+ # text highlighting and displaying.
+ $query=get_search_query(false);
+ $query=str_replace('"','',$query);
+ $query=esc_html($query);
+
+ $query = explode(' ', $query);
+
+ echo generate_excerpt($text, $query, $excerptLength);
- print_r($query);
-
- echo generate_excerpt($text, $query, $length);
}
From 591dfd473f259816cf230abbc5c12c18c2849265 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Tue, 28 Jul 2020 19:21:10 +0200
Subject: [PATCH 07/10] fix logo size, tweaks to Makefile
---
Makefile | 28 +++++++++++++++++-----------
kit/css/header.css | 2 --
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/Makefile b/Makefile
index fdcaf7b..ed10c4f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,31 +1,37 @@
+DOCKER_HOST="playground.pi"
+SITE_URL="beta.saai.digital"
+PROJECT_NAME="web-wordpress-kit"
+CONTAINER_NAME_WORDPRESS="${PROJECT_NAME}_wordpress"
+CONTAINER_NAME_DB="${PROJECT_NAME}_db"
+LISTENING_PORT=8080
+
docker_deploy:
docker run --rm -it \
-v /tmp/backup:/backup -v /var/lib/docker:/docker \
- -v $(shell pwd)/kit:/docker/volumes/web-wordpress-kit_wordpress/_data/wp-content/themes/kit \
+ -v $(shell pwd)/kit:/docker/volumes/${CONTAINER_NAME_WORDPRESS}/_data/wp-content/themes/kit \
alpine:edge tar cpfz /backup/volumes.tgz /docker/volumes/
- rsync --progress /tmp/backup/volumes.tgz playground.pi:/tmp/
+ rsync --progress /tmp/backup/volumes.tgz ${DOCKER_HOST}:/tmp/
- -DOCKER_HOST="ssh://playground.pi" docker stop web-wordpress-kit_db_1 web-wordpress-kit_wordpress_1
- -DOCKER_HOST="ssh://playground.pi" docker rm web-wordpress-kit_db_1 web-wordpress-kit_wordpress_1
- -DOCKER_HOST="ssh://playground.pi" docker volume rm web-wordpress-kit_db web-wordpress-kit_wordpress
+ -DOCKER_HOST="ssh://${DOCKER_HOST}" docker stop ${CONTAINER_NAME_WORDPRESS}_1 ${CONTAINER_NAME_DB}_1
+ -DOCKER_HOST="ssh://${DOCKER_HOST}" docker rm ${CONTAINER_NAME_WORDPRESS}_1 ${CONTAINER_NAME_DB}_1
+ -DOCKER_HOST="ssh://${DOCKER_HOST}" docker volume rm ${CONTAINER_NAME_WORDPRESS} ${CONTAINER_NAME_DB}
- DOCKER_HOST="ssh://playground.pi" docker run --rm -it \
+ DOCKER_HOST="ssh://${DOCKER_HOST}" docker run --rm -it \
-v /var/lib/docker:/docker \
-v /tmp:/volume-backup \
alpine:edge tar --strip-components=2 -xpvf /volume-backup/volumes.tgz -C /docker/volumes/
- DOCKER_HOST="ssh://playground.pi" docker run --rm -it \
+ DOCKER_HOST="ssh://${DOCKER_HOST}" docker run --rm -it \
-v /var/lib/docker:/docker \
-v /tmp:/volume-backup \
- alpine:edge sed -i 81idefine\\\(\\\'WP_SITEURL\\\',\\\'https://beta.saai.digital\\\'\\\)\\\;\\ndefine\\\(\\\'WP_HOME\\\',\\\'https://beta.saai.digital\\\'\\\)\\\; /docker/volumes/web-wordpress-kit_wordpress/_data/wp-config.php
+ alpine:edge sed -i 81idefine\\\(\\\'WP_SITEURL\\\',\\\'https://${SITE_URL}\\\'\\\)\\\;\\ndefine\\\(\\\'WP_HOME\\\',\\\'https://${SITE_URL}\\\'\\\)\\\; /docker/volumes/${CONTAINER_NAME_WORDPRESS}/_data/wp-config.php
# # Need to fix MaxSessions in remote ssh daemon https://github.com/docker/compose/issues/6463
- # # Disable nftables on remote host
cp wordpress.yml /tmp/wordpress.yml
sed -e '/kit/ s/^#*/#/' -i /tmp/wordpress.yml
- DOCKER_HOST="ssh://playground.pi" docker-compose -p web-wordpress-kit -f /tmp/wordpress.yml create
- DOCKER_HOST="ssh://playground.pi" docker-compose -p web-wordpress-kit -f /tmp/wordpress.yml start
+ DOCKER_HOST="ssh://${DOCKER_HOST}" docker-compose -p ${PROJECT_NAME} -f /tmp/wordpress.yml create
+ DOCKER_HOST="ssh://${DOCKER_HOST}" docker-compose -p ${PROJECT_NAME} -f /tmp/wordpress.yml start
docker_up:
docker-compose -f wordpress.yml up
diff --git a/kit/css/header.css b/kit/css/header.css
index 8d29c2a..eafb608 100644
--- a/kit/css/header.css
+++ b/kit/css/header.css
@@ -71,7 +71,6 @@ header:not(.sticky-header) .header-button-container {
.header-logo {
display: block;
- width: 10rem;
height: 4.61111rem;
}
@@ -81,7 +80,6 @@ header:not(.sticky-header) .header-button-container {
.header-logo-mobile {
display: none;
- width: 6.11111rem;
height: 2.77778rem;
}
From 9c246b666599a0dc0a003b0e35a19ef650b56ed4 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Sun, 2 Aug 2020 12:22:52 +0200
Subject: [PATCH 08/10] update Makefile remote deploy script
---
Makefile | 13 ++++++-------
wordpress.yml | 2 +-
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index ed10c4f..c989b2b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,16 +1,15 @@
-DOCKER_HOST="playground.pi"
-SITE_URL="beta.saai.digital"
-PROJECT_NAME="web-wordpress-kit"
-CONTAINER_NAME_WORDPRESS="${PROJECT_NAME}_wordpress"
-CONTAINER_NAME_DB="${PROJECT_NAME}_db"
-LISTENING_PORT=8080
+DOCKER_HOST=playground.pi
+SITE_URL=beta.saai.digital
+PROJECT_NAME=web-wordpress-kit
+CONTAINER_NAME_WORDPRESS=${PROJECT_NAME}_wordpress
+CONTAINER_NAME_DB=${PROJECT_NAME}_db
docker_deploy:
docker run --rm -it \
-v /tmp/backup:/backup -v /var/lib/docker:/docker \
-v $(shell pwd)/kit:/docker/volumes/${CONTAINER_NAME_WORDPRESS}/_data/wp-content/themes/kit \
- alpine:edge tar cpfz /backup/volumes.tgz /docker/volumes/
+ alpine:edge tar cpfz /backup/volumes.tgz /docker/volumes/${CONTAINER_NAME_WORDPRESS} /docker/volumes/${CONTAINER_NAME_DB}
rsync --progress /tmp/backup/volumes.tgz ${DOCKER_HOST}:/tmp/
-DOCKER_HOST="ssh://${DOCKER_HOST}" docker stop ${CONTAINER_NAME_WORDPRESS}_1 ${CONTAINER_NAME_DB}_1
diff --git a/wordpress.yml b/wordpress.yml
index f16bc39..f6e83df 100644
--- a/wordpress.yml
+++ b/wordpress.yml
@@ -4,7 +4,7 @@ services:
wordpress:
image: wordpress
- restart: always
+ restart: on-failure
ports:
- 8080:80
environment:
From 30182d3fc8c8dbb35ffcc7936840086c7230fa94 Mon Sep 17 00:00:00 2001
From: Jonas Heinrich
Date: Sun, 2 Aug 2020 12:56:41 +0200
Subject: [PATCH 09/10] fix display favicon by customizer
---
{kit/img => dist}/favicon-196x196.png | Bin
kit/header.php | 22 ----------------------
kit/img/favicon-16x16.png | Bin 477 -> 0 bytes
kit/img/favicon-32x32.png | Bin 995 -> 0 bytes
kit/img/favicon-96x96.png | Bin 4605 -> 0 bytes
5 files changed, 22 deletions(-)
rename {kit/img => dist}/favicon-196x196.png (100%)
delete mode 100644 kit/img/favicon-16x16.png
delete mode 100644 kit/img/favicon-32x32.png
delete mode 100644 kit/img/favicon-96x96.png
diff --git a/kit/img/favicon-196x196.png b/dist/favicon-196x196.png
similarity index 100%
rename from kit/img/favicon-196x196.png
rename to dist/favicon-196x196.png
diff --git a/kit/header.php b/kit/header.php
index d0ab406..8d0e30e 100644
--- a/kit/header.php
+++ b/kit/header.php
@@ -22,28 +22,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-