Skip to content

Commit

Permalink
Merge branch 'master' into TMS-1059
Browse files Browse the repository at this point in the history
  • Loading branch information
eebbi committed Nov 24, 2024
2 parents cb95245 + ae3febd commit c0f7032
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Add "Sign up"- & "Purchase tickets"-links
- Add translation to homepage link
- Fix regex pattern for short description
- TMS-1087: Event-page main image style change
- TMS-1083: Change event short description to be used from API

## [1.59.2] - 2024-11-19

- TMS-1088: Add fields to redipress schema

## [1.59.1] - 2024-10-28

Expand Down
12 changes: 3 additions & 9 deletions assets/styles/views/_page-event.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,9 @@
.page-template-page-event {
.entry {
&__hero-image {
height: 18.25rem;

@include from($tablet) {
height: 22rem;
}

@include from($desktop) {
height: 31.25rem;
}
height: auto;
aspect-ratio: 16 / 9;
background-size: contain;
}

&__hero-info {
Expand Down
27 changes: 2 additions & 25 deletions lib/Eventz.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static function normalize_event( $event ) : array {

return [
'name' => $event->name ?? null,
'short_description' => static::get_short_description( $event ) ?? null,
'short_description' => nl2br( $event->descriptionShort ) ?? null,
'description' => nl2br( $event->description ) ?? null,
'date_title' => __( 'Dates', 'tms-theme-base' ),
'date' => static::get_event_date( $event ),
Expand Down Expand Up @@ -199,7 +199,7 @@ public static function normalize_event_title( $event ) : array {
*/
public static function normalize_event_description( $event ) : array {
return [
'short_description' => static::get_short_description( $event ) ?? null,
'short_description' => nl2br( $event->descriptionShort ) ?? null,
];
}

Expand Down Expand Up @@ -642,27 +642,4 @@ public static function compare_dates( $start, $end ) {
$end_time->format( 'H.i' )
);
}

/**
* Generate short description.
*
* @param object $event Event object.
*
* @return string|null
*/
public static function get_short_description( $event ) {

if ( empty( $event->description ) ) {
return null;
}

// Define a regular expression pattern to match the first two sentences
// This also takes   and closing html-tags after the dot into consideration
$pattern = '/^(.*?[.!?](?:\s|&nbsp;|<\/[^>]+>)+)(.*?[.!?](?:\s|&nbsp;|<\/[^>]+>)+)/';

// Use preg_match() to find the first two sentences
if ( preg_match( $pattern, $event->description, $matches ) ) {
return $matches[1] . ' ' . $matches[2];
}
}
}
11 changes: 11 additions & 0 deletions models/search.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,17 @@ public static function set_fields_weight( array $fields ) : array {
$post_excerpt = array_search( 'post_excerpt', array_column( $fields, 'name' ), true );
$fields[ $post_excerpt ]->weight = 5;

// Include fields
$fields[] = new \Geniem\RediPress\Entity\NumericField( [
'name' => 'is_active',
] );
$fields[] = new \Geniem\RediPress\Entity\NumericField( [
'name' => 'apply_start',
] );
$fields[] = new \Geniem\RediPress\Entity\NumericField( [
'name' => 'apply_end',
] );

return $fields;
}

Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Theme Name: TMS Theme Base
* Description: Tampere Multisite Base Theme
* Domain Path: /lang
* Version: 1.59.1
* Version: 1.59.2
* Author: Geniem
* Author URI: https://geniem.fi
* Text Domain: tms-theme-base
Expand Down

0 comments on commit c0f7032

Please sign in to comment.