Skip to content

Commit

Permalink
gmaps and event styles
Browse files Browse the repository at this point in the history
  • Loading branch information
frebro committed Apr 22, 2012
1 parent c537c72 commit bf52cb7
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 52 deletions.
84 changes: 44 additions & 40 deletions content-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,49 +14,53 @@
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'synack' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
<?php endif; ?>

<?php the_title('<h1 class="entry-title">', '</h1>'); ?>

<?php if ( !is_home() && has_post_thumbnail() ) : // check if the post has a Post Thumbnail assigned to it. ?>
<figure class="post-thumbnail">
<?php
if ( is_singular() ) : // large thumbnails for singular posts
the_post_thumbnail('large');

// print thumbnail title and/or description, if available
$thumbnail = get_post( get_post_thumbnail_id( $post->ID ) );
if ( $thumbnail->post_excerpt || $thumbnail->post_content ) :
?>
<figcaption class="post-thumbnail-caption">
<?php
if ( $thumbnail->post_excerpt )
echo '<span class="post-thumbnail-title">'.$thumbnail->post_excerpt.'</span>';

if ( $thumbnail->post_excerpt && $thumbnail->post_content )
echo '<span class="sep">&rsaquo;</span>';

if ( $thumbnail->post_content )
echo '<span class="post-thumbnail-description">'.$thumbnail->post_content.'</span>';
?>
</figcaption>
<?php endif; // $thumbnail->post_excerpt || $thumbnail->post_content ?>

<?php
else : // medium thumbnails for non-singular posts
the_post_thumbnail('medium');
endif; // is_singular()
?>
</figure>
<?php endif; // is_home() && has_post_thumbnail() ?>
<?php if ( !is_home() ) : // print title above thumbnail when not on the home page ?>
<?php the_title('<h1 class="entry-title">', '</h1>'); ?>
<?php endif; // !is_home() ?>

<?php if ( has_post_thumbnail() ) : // check if the post has a Post Thumbnail assigned to it. ?>
<figure class="post-thumbnail">
<?php
if ( is_home() ):
the_post_thumbnail('thumbnail');
else:
the_post_thumbnail('large');
endif;
?>
</figure>
<?php endif; // has_post_thumbnail() ?>

<?php if ( is_home() ) : // print title below thumbnail on home page ?>
<?php the_title('<h1 class="entry-title">', '</h1>'); ?>
<?php endif; // is_home() ?>

<?php if ( !is_singular() ) : // close title and thumbnail link ?>
</a>
<?php endif; ?>
<?php endif; //!is_singular() ?>

<?php
// Print the meta info on the home page
if (is_home()):

<?php if ( 'post' == get_post_type() ) : // print publish info ?>
<p class="pub-info">
<?php synack_posted_on(); ?>
</p>
<?php endif; // 'post' == get_post_type() ?>
// The date strings
if ( eo_get_the_start('Y-m-d') == date('Y-m-d') ):
$datestr = __('Today', 'unhyped');
elseif ( eo_get_the_start('Y-m-d') == date('Y-m-d', time()+86400) ):
$datestr = __('Tomorrow', 'unhyped');
else:
$datestr = eo_get_the_start('Y-m-d');
endif;

// The venue strings
$venue = eo_get_venue_name();
$address = eo_get_venue_address();

echo '<p class="entry-meta"><span class="date">'.$datestr.'</span>';
if (!empty($venue)) echo ' at <span class="location">'.$venue.'</span>';
if (!empty($address['address']) && !empty($address['postcode'])) echo ' <a class="address" href="http://maps.google.com/maps?q='.urlencode($address['address'].' '.$address['postcode']).'">'.$address['address'].'</a>';

endif; // is_home()
?>

</header><!-- .entry-header -->

Expand All @@ -65,7 +69,7 @@
if ( is_singular() ) :
the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'synack' ) );
else :
the_excerpt();
the_pretty_excerpt();
endif;
?>
</div><!-- .entry-content -->
Expand Down
32 changes: 32 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,35 @@ function unhyped_widgets_init() {
) );
}
add_action( 'widgets_init', 'unhyped_widgets_init' );

/**
* A prettier excerpt template tag
* It cuts off at the end of the sentence preceding the cut-off character.
*/
function the_pretty_excerpt($length=128, $allowed_tags='') { // Max excerpt length is set in characters
global $post;

$text = $post->post_excerpt;

if ('' == $text) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$text = strip_shortcodes($text); // optional, recommended
$text = strip_tags($text, $allowed_tags); // use ' $text = strip_tags($text,'<p><a>'); ' if you want to keep some tags

$text = substr($text, 0, $length);
$excerpt = reverse_strrchr($text, '.', 1);
if($excerpt) {
echo apply_filters('the_excerpt', $excerpt);
} else {
echo apply_filters('the_excerpt', $text);
}
}

// Returns the portion of haystack which goes until the last occurrence of needle
function reverse_strrchr($haystack, $needle, $trail) {
return strrpos($haystack, $needle) ? substr($haystack, 0, strrpos($haystack, $needle) + $trail) : false;
}

5 changes: 1 addition & 4 deletions inc/unhyped_featured_event_widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,10 @@ function widget($args, $instance) {
echo '<h2 class="entry-title">'.$event->post_title.'</h2>';
echo get_the_post_thumbnail($event_id, 'medium');
echo '<p class="entry-meta"><span class="date">'.$datestr.'</span>';
if (!empty($venue)) echo 'at <span class="location">'.$venue.'</span>';
if (!empty($venue)) echo ' at <span class="location">'.$venue.'</span>';
echo '</p>';
echo '<p class="entry-excerpt">'.$event->post_excerpt.'</p>';
echo '</a>';
echo '<!--';
print_r($event);
echo '-->';
?>
</div>

Expand Down
43 changes: 39 additions & 4 deletions sass/partials/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,24 @@ blockquote {
@include box;
padding: $base-vmargin $base-hmargin;
margin-bottom: .5 * $base-vmargin;
.entry-meta,
.entry-excerpt {
font-size: $small-font-size;
}
.entry-meta {
a {
@include unstyled-link;
}
color: $mute-color;
.address {
&:before {
content: '';
}
}
}
.meta-nav {
@include hidden;
}
}
// Single view styles
body.singular & {
Expand All @@ -209,10 +227,12 @@ blockquote {
color: $bg-color;
padding: .25 * $base-vmargin .5 * $base-hmargin;
}
img {
@include border-bottom-radius;
max-width: 100%;
height: auto;
.post-thumbnail {
img {
@include border-bottom-radius;
max-width: 100%;
height: auto;
}
}
}
// No sidebar view styles
Expand All @@ -225,6 +245,14 @@ blockquote {
.event {
float: left;
width: 64%;
.post-thumbnail {
float: right;
margin-top: .5 * $base-vmargin;
margin-left: $base-hmargin;
img {
@include border-radius;
}
}
}
.page-title {
position: absolute;
Expand All @@ -238,6 +266,13 @@ blockquote {
}

#complementary {
.meta {
img {
@include border-radius;
width: 100%;
height: auto;
}
}
.meta,
.sidebar {
@include box;
Expand Down
28 changes: 25 additions & 3 deletions single-event.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,31 @@

<aside id="complementary" role="complementary">
<div class="meta">
<h2>Hyped by</h2>
<p>Marek Wolski</p>
<p><a href="#">Add to Google Calendar</a></p>
<?php
// The date strings
if ( eo_get_the_start('Y-m-d') == date('Y-m-d') ):
$datestr = __('Today', 'unhyped');
elseif ( eo_get_the_start('Y-m-d') == date('Y-m-d', time()+86400) ):
$datestr = __('Tomorrow', 'unhyped');
else:
$datestr = eo_get_the_start('Y-m-d');
endif;

// The venue strings
$venue = eo_get_venue_name();
$address = eo_get_venue_address();

if (!empty($address['address']) && !empty($address['postcode'])) echo '<img class="gmap" src="http://maps.googleapis.com/maps/api/staticmap?maptype=roadmap&zoom=14&size=300x300&markers=color:0xFF0033|'.urlencode($address['address'].' '.$address['postcode']).'&sensor=false">';

// Event and venue meta
echo '<p class="entry-meta"><span class="date">'.$datestr.'</span>';
if (!empty($venue)) echo ' at <span class="location">'.$venue.'</span>';
if (!empty($address['address']) && !empty($address['postcode'])) echo '<br><a class="address" href="http://maps.google.com/maps?q='.urlencode($address['address'].' '.$address['postcode']).'">'.$address['address'].'</a>';
echo '</p>';

// Google calendar link
echo '<p><a class="gcal" href="'.eo_get_the_GoogleLink().'">Add to Google Calendar</a></p>';
?>
</div>
<?php get_sidebar(); ?>
</aside><!-- #complementary -->
Expand Down
Loading

0 comments on commit bf52cb7

Please sign in to comment.