Browse Source

Desk: add Recent Photos Lychee stream, remove dead photo() scraper

- Enqueue the Lychee embed CSS/JS in dw_scripts() scoped to is_page('desk')
  (the branch also matches archive/search, hence the guard).
- New 'Recent Photos ( all @ /photo )' row above Docs/Notes/Lists: 10 photos laid
  out 2 rows of 5 (target col/row 175px), embed's own header suppressed
  (data-header-placement=none) so the desk-style h4 is the only heading.
- Remove the dead photo() scraper from inc/utils.php — no callers, still pointed
  at the old photo.davidawindham.com domain, superseded by the embed.
windhamdavid 2 days ago
parent
commit
770126e352
3 changed files with 24 additions and 16 deletions
  1. 7 0
      functions.php
  2. 0 16
      inc/utils.php
  3. 17 0
      page-desk.php

+ 7 - 0
functions.php

@@ -204,6 +204,13 @@ function dw_scripts() {
 		global $wp_rewrite;
 		wp_enqueue_script( 'jquery', get_template_directory_uri() . '/js/v4-script.min.js', '', '', true );
 		wp_enqueue_script( 'desk', get_template_directory_uri() . '/js/desk.js', '', '', true );
+		if ( is_page('desk') ) {
+			// Lychee photo-stream embed (davidwindham.com/photo). The config <div> lives
+			// in page-desk.php; this loads the embed lib. Not on archive/search (which
+			// share this branch), hence the is_page guard.
+			wp_enqueue_style( 'lychee-embed', 'https://davidwindham.com/photo/embed/lychee-embed.css', array(), '1.0.0' );
+			wp_enqueue_script( 'lychee-embed', 'https://davidwindham.com/photo/embed/lychee-embed.js', array(), '1.0.0', true );
+		}
 		wp_enqueue_script( '_s_backbone-loop', get_template_directory_uri() . '/js/loop.js', array( 'jquery', 'backbone', 'underscore', 'wp-api'  ), '1.0', true );
 		$queried_object = get_queried_object();
 		$local = array(

+ 0 - 16
inc/utils.php

@@ -442,22 +442,6 @@ function lists_code() {
 	}
 }
 
-function photo() {
-	require_once('lib/html_dom.php');
-
-	$url = 'https://photo.davidwindham.com/#16734437965516';
-	$html = file_get_html($url);
-	if (!$html) return;
-	$i = 0;
-	foreach ($html->find('.photo .overlay h1') as $li) {
-    if (!empty($html)) {
-      echo str_replace('href="/', 'href="https://photo.davidawindham.com/', $li . '&nbsp;');
-      if (++$i == 18) break;
-    }
-  }
-}
-
-
 //function mastodon() {
 //	require_once('lib/html_dom.php');
 //

+ 17 - 0
page-desk.php

@@ -63,6 +63,23 @@ get_header(); ?>
 						</ul>
 					</div>
 				</div>
+				<div class="row mt-3 pb-2">
+					<div class="col-lg-12">
+						<h4 class="fw-bold mt-2">Recent Photos <span class="text-muted fw-light"><small>( all @ <a href="/photo/">/photo )</a></small></span></h4>
+						<div
+							data-lychee-embed
+							data-api-url="https://davidwindham.com/photo"
+							data-mode="stream"
+							data-layout="square"
+							data-spacing="8"
+							data-target-row-height="175"
+							data-target-column-width="175"
+							data-max-photos="10"
+							data-sort-order="desc"
+							data-header-placement="none"
+						></div>
+					</div>
+				</div>
 				<div class="row mt-3 pb-2">
 					<div class="col-lg-4">
 						<h4 class="fw-bold mt-2">Docs</h4>