diff --git a/Makefile b/Makefile index fdcaf7b..26387a4 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,36 @@ +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/web-wordpress-kit_wordpress/_data/wp-content/themes/kit \ - alpine:edge tar cpfz /backup/volumes.tgz /docker/volumes/ - rsync --progress /tmp/backup/volumes.tgz playground.pi:/tmp/ + -v $(shell pwd)/kit:/docker/volumes/${CONTAINER_NAME_WORDPRESS}/_data/wp-content/themes/kit \ + 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://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 @@ -39,3 +44,7 @@ generate_pot: # generate mo file \ msgfmt -o kit/languages/$${i18n}.mo kit/languages/$${i18n}.po ; \ done + +install: + mkdir -p $(DESTDIR) + cp -r kit $(DESTDIR)/ 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/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; -} 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; } diff --git a/kit/functions.php b/kit/functions.php index 5893f05..7000ac5 100644 --- a/kit/functions.php +++ b/kit/functions.php @@ -431,32 +431,70 @@ 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 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; } - $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); + + } + + $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() { + + # 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); + } -add_filter('the_excerpt', 'highlight_search_term'); 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 @@ - - - - - - - - - - - - - - - - - - - - - -