bobbingwide / bigram Goto Github PK
View Code? Open in Web Editor NEWSimply because ... one word won't do
Home Page: https://seriouslybonkers.com
License: GNU General Public License v2.0
Simply because ... one word won't do
Home Page: https://seriouslybonkers.com
License: GNU General Public License v2.0
On the bigram's home page, archive pages and each singular page that displays a bigram there's a post meta field
that displays how many times the bigram has been seen.
The display is pretty basic
Seen before: n,nnn times
where n,nnn is the internationalised formatted number.
The Genesis-SB theme displays this automatically using the PHP function genesis_sb_seen_before()
For the SB theme I want to display this metadata using a block.
Block to display the post meta value field name _seen_before
See also bobbingwide/sb#10
register_post_meta
to make the field accessible using the REST APIThe block name will be bigram/seen-before
Since the value is supposed to be auto-incremented the post meta data doesn't need to be updateable.
But we may as well write the code to allow it to be updated as this will be necessary for other fields.
While trying to reproduce the home page for seriouslybonkers.com in the SB theme I saw a lot of posts which had incorrectly formatted "read more" links.
The screenshot shows the end of a post which doesn't exhibit the problem followed by two which do.
Both of these postsonly contain automatically generated content - a classic block.
<!--more-->Sampled from Seize Bees.
It would appear that the post-content block is formatting the read more link incorrectly.
The aria-label looks iffy.
<div class="entry-content wp-block-post-content">
<p>
<a href="https://s.b/bigram/bigram/sweat-bees/#more-5999"
class="more-link">
<span aria-label="Continue reading <a href="https://s.b/bigram/bigram/sweat-bees">Sweat Bees</a>“>(more…)</span>
</a>
</p>
</div>
On the Home and Archive pages the (Edit) link that is displayed following the Last updated field does not appear to operate as a link.
Noted on iPad in landscape mode, it doesn't work in Safari but does in Chrome.
In bobbingwide/genesis-SB#2 we outline a single page view for selecting and displaying SB bigrams.
The component parts of the solution are expected to consist of:
s-letter
and b-letter
)s-letter
and b-letter
when creating / updating a bigram'show_in_rest'
true.I just took a photo on my iPhone and uploaded it to bigram.co.uk but it didn't appear immediately. It turns out that it is Scheduled. The photo was taken at 11:56 so that's the time used to create both the attachment and the bigram CPT.
What needs to be done to ensure it gets published immediately?
In Settings > General the timezone is shown as
Universal time (GMT) is 2017-06-22 11:15:59
which is behind the time of the photo.
Just wait a while before uploading photos.
Either, adjust the publication time so that it's no greater than the current time
OR detect that it's BST and subtract an hour from the image time.
OR a combination of the above.
When visiting the site bigram.co.uk I often just type the S and B word in the URL.
It would be nice if this could be detected and converted into the most appropriate request.
How do we know when it's a post or page and when it's a bigram?
The permalink for bigrams is currently "/bigram/"
If we change it so that it doesn't have a prefix what will happen when
a user enters an URL like: https://bigram.co.uk/s-word b-word
?
Currently we get a 404 Not Found.
When the request is being parsed we get an opportunity to filter the values. If we see a request for a bigram with spaces we can convert the spaces ( %20 ) to hyphens.
If there are
we can change the request to be /bigram/s-word-b-word
Then there's more chance of finding the bigram.
When I created a gallery with both captions and alt text an SB in the alt text was converted to a link. This caused formatting problems in the front end.
https://seriouslybonkers.com/bigram/stupidly-brilliant/
<figure class="wp-block-image size-medium"><img loading="lazy" decoding="async" width="400" height="400" data-id="7438" src="https://seriouslybonkers.com/wp-content/uploads/2024/03/20240221-165908-s-b-400x400.png" alt="Stupidly brilliant - <a href="https://seriouslybonkers.com/bigram/stippled-brush">stippled brush</a>” class=”wp-image-7438″ srcset=”https://seriouslybonkers.com/wp-content/uploads/2024/03/20240221-165908-s-b-400×400.png 400w, https://seriouslybonkers.com/wp-content/uploads/2024/03/20240221-165908-s-b-150×150.png 150w, https://seriouslybonkers.com/wp-content/uploads/2024/03/20240221-165908-s-b-768×768.png 768w, https://seriouslybonkers.com/wp-content/uploads/2024/03/20240221-165908-s-b.png 1024w” sizes=”(max-width: 400px) 100vw, 400px” /><figcaption class="wp-element-caption">Stippled brush</figcaption></figure>
</figure>
remove the SB from the alt text
In Genesis-SB the Seen before: field is displayed by genesis_sb_seen_before()
function genesis_sb_seen_before() {
$seen_before = genesis_sb_increment_seen_before();
echo '<div class="seen-before">';
_e( 'Seen before: ', 'genesis-SB' );
echo '</span>';
echo '<span class="seen-before-value">';
$times = _n( '%1$s time', '%1$s times', $seen_before, "genesis-SB" );
printf( $times, number_format_i18n( $seen_before ) );
echo '</div>';
}
This code automatically increments the value before displaying it.
Seen before: n,nnn times
.For the replacement Full Site Editing theme SB: Second Byte
[bw_fields _seen_before]
shortcode or an equivalent Gutenberg block.'#theme' => false
to '#theme' => true
.Seen before: 1 time
or Seen before: 0 times
.This issue is to change the field definition.
When creating a new SB bigram we often use other SB bigrams in the definition. e.g. Sam's Bar Sourdough Burger. Each of these SB bigrams (we'll call them SB's from now on) needs its own entry.
It would be nice if
Part of the logic may need to be developed in the theme.
The Submit Bigram page used the [bw_new] shortcode to create a new post with the title of the bigram.
It doesn't check for an existing post.
When an image is being uploaded and the bigram was in the original SB list, or has been sampled or seen before then it makes sense to check if the bigram already exists. If it doesn't have a featured image then, rather than create a new one, we can reuse that post.
[bw_new]
or similar.If we had an export CSV file of bigrams then we could satisfy some requirements.
When I recently created https://seriouslybonkers.com/bigram/sharing-board-2/
the first entry "Scowl because" was not sampled.
To correct this I edited the post and converted it to blocks.
I created a list of the words, then tried a paragraph with line breaks and finally a preformatted block.
Sampling didn't work until I changed the paragraph to
<!-- wp:paragraph -->
<p> Scowl because, school bear, so breakfast, squirrels believe,
sometimes breathing, spoil blink, snuggle bubble, shadows barking,
should be and see-saw bedstead. </p>
<!-- /wp:paragraph -->
Update code to run without problems in PHP 8.1 and 8.2
A recent WordPress core update announced that uploaded images would be correctly rotated.
This didn't happen when I uploaded Santorini Bike from my iPad.
Investigate why not.
Using Jetpack’s publicise method a new bigram created using the Submit bigram page only has a two word title. We need to be able to enhance the message with more words.
When a user performs a search with words starting S and B, both words exist but the exact result is not returned then we should create a new bigram with a category of Searched Before
Similarly, when we display a 404 page - this could create a Seen Before
.
When a post is an exact match for a search then the number of times it's been searched for should be displayed.
There's something very wrong with the logic that detects SB's in content and converts them into a link.
In this example the content was
<!-- wp:paragraph -->
<p>All I asked for was </p>
<!-- /wp:paragraph -->
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"border":{"width":"1px","color":"#eeeeee","radius":"12px"}},"layout":{"type":"constrained"}} -->
<div class="wp-block-group has-border-color" style="border-color:#eeeeee;border-width:1px;border-radius:12px;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:paragraph -->
<p>Santa's belt.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->
Insert a space before Santa's
The first pass routine(s) developed for #2 will need to be extended to allow images to be attached from whatever folder they happen to be in. It should also be possible to enter free form body text.
The bigram plugin should implement the 'run_bigram.php' action, invoking a routine to create the bigram and associated attachment.
It would be nice if the routine could
The solution will need a theme specially built for the purpose.
Sometimes several bigrams are created on submission. The code should not allow the same bigram to be submitted twice in a row. I suspect it's not properly checking for an upload file.
There are some bigrams which are not correctly detected by the logic that creates the links on the front end.
examples
Sixty-sixth birthday
Sauce Béarnaise
For sixty-sixth birthday the link is to https://seriouslybonkers.com/bigram/sixty-birthday
For the other one it's to Sauce B, the e acute breaks the parsing.
I sometimes see SB's when using my iPhone / iPad and take a quick screen capture. I've decided that these should be classified as Surf Bite. It should be possible to automatically detect screen captures based on information in the EXIF data.
tbc
Maybe there should also be Selfie Bomb... just because some selfies have the same image dimensions as screen captures.
Write some blocks which can be used to display information in Statistically boring.
Use SQL like this to display the chart of SB's counts by length
SELECT length( post_title), count(*) FROM `wp_posts` where post_type = 'bigram' and post_status = 'publish' group by length( post_title )
Perhaps another to count them by second letters?
Changes to WooCommerce in v8.0.0 mean that the bigram_pre_get_posts()
action hook is being invoked before the main query has been run. The call to is_category()
produces a Doing it wrong error.
See bobbingwide/bobbingwide#101 (comment)
Use $query->is_category()
instead of is_category()
bigram's blocks are currently built with wp-scripts 23.6.0
Update to latest version 26.16.0
The SB list ( https://github.com/bobbingwide/bigram/blob/master/admin/SB.txt ) was originally created using first letter capitalisation. This allowed for proper names.
In the current website(s) implementation
It depends on where they're used and how they're created.
We need to standardise the capitalisation of the first letters based on how they're used.
Here we'll use examples with S-word B-word as the two words.
Field | Value |
---|---|
Title | S-word B-word |
slug | S-word-B-word |
Category | S-word B-word |
s-word taxonomy term | s-word |
b-word taxonomy term | b-word |
submitted image filename | S-word B-word.jpg |
Where the logic should apply
For the SB theme the page-sb.html
template will need to invoke the react-SB JavaScript to display the React page which displays the SB's using the REST API.
bigram/reactsb
.While developing the first version of the genesis-SB theme for http://www.bigram.co.uk I noticed that there was a conflict between the taxonomy named 's' and the default WordPress behaviour for search.
I asked about it in the ukgenesis slack channel and @gamajo correctly pointed out that s
is a reserved term. So I said I'd rename the custom taxonomies
from s
to s-word
and from b
to b-word
@benfurfie then suggested I name them semantically. I replied I'd never forget, but @gamajo asked what happens when someone else joins / takes over the project.
So here's the issue that addresses this.
When attaching an image to an existing bigram it should be put through similar logic to that invoked when a new bigram is being created:
On my PC I can use batch processing to create a new bigram.
The process is still a little long winded though.
sb.bat
file.@echo off
rem (C) Copyright Bobbing Wide 2016
setlocal
set cd=%CD%
cd \apache\htdocs\bigram\wp-content\plugins\bigram
oikwp bigram.php %* dir="%cd%"
endlocal
I want to be able to create new bigrams from screen captures on my iPhone / iPad, using a simple upload method directly into the site.
We need a routine to populate the database with photos and screenshots containing SB bigrams.
For the first pass we want to reload the database with the photos that were in the Drupal version of the site.
For each image the routine needs to create a bigram and attach the image.
More than one image can be attached to a bigram.
The logic should create the bigram with the date of the image.
The logic should also create as much information as possible:
In the SB theme we need to display some additional Search Banter on the search results page.
For details of what the block needs to display see the Search results section in bobbingwide/sb#24
bigram/search-banter
.Implementation notes
At PHPHants this month we were discussing input fields and search and I became aware of the HTML <datalist>
tag.
When combined with an input field this sounds like the ideal field for a suggestions box.
It can be used to enhance/replace the Search box with one field for the S-word and one for the B-word.
To implement a search which will find matches for the S-word or B-word in preference to the title / content search that's currently implemented.
Develop a "Suggestions box" block as a form, similar to search.
It would have two input fields with datalists and a submit / search button.
<input list="swords" name="sword" id="sword">
<datalist id="swords">
<option value="s">
...
<option value="systematic">
</datalist>
See https://www.w3schools.com/TAGs/tag_datalist.asp for a working example.
The S-word datalist would be populated from the S-word taxonomy.
The B-word datalist from the B-word taxonomy.
I understand that Google Chrome limits the number of options in a datalist to 1024.
That could be a problem since we already have nearly 1600 S-words and over 1200 B-words.
bigrams and their taxonomies should be REST enabled so that we can use the block editor with them. Currently on https://seriouslybonkers.com bigrams show up with the classic editor. Find out why this is so, even when the CPT is marked as Show in Rest.
While investigating bobbingwide/oik-fields/issues/24 I created a new version of the site under WPMS. There I noticed a number of problems associated with the value being set for _wp_attached_file
. Whereas single site appeared to work with fully qualified values, WPMS baulked.
The attachment file, being created by wp_insert_attachment(), was being passed $file_return['url']
from wp_handle_upload(). The value being stored therefore contained http: or https: and all the rest of the path to the file.
This was causing a problem on the subsequent file display, leading to 500 internal server errors.
The value that should be stored in _wp_attached_file
is the relative path under the uploads directory for the site. e.g. 2017/05/s-b-n.jpg
. Note: No preceeding slash; indicating a relative file name.
We can't simply use the file name first thought of, since this may be a duplicate name. Therefore we do need the unique file name, generated in wp_handle_upload, but we have to strip the basedir
part of the file name, returned from wp_upload_dir(), plus the following '/' to create the value to store in _wp_attached_file
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.