version 2.5 - Winnowing Hall (tbd)
+ + Added a thumbnail by talking to Google page speed API
+ Planned was a full page snapshot, but only got the thumbnail.
+ Needs some more work with headless chrome.
+
version 2.4 - Seven Portals (2020-02-16)
+ Now including update instructions
--- /dev/null
+While editing a link you can request thumbnail of the given link at the time.
+It uses the Google page insights API to get a thumbnail.
+
+It will be created if the option is actived. To remove uncheck the option.
+To refresh uncheck the option. Save. This will delete the data.
+Check the option again and the thumbnail will be created again.
\ No newline at end of file
$this->_categories();
$this->_image();
$this->_private();
+ $this->_snapshot();
}
}
# add stuff
$this->_image();
- $this->_snapshot();
}
}
if ($returnId === true) {
$ret = $this->DB->insert_id;
}
+ else {
+ error_log('ERROR Failed to rcreate link: '.var_export($data,true));
+ }
return $ret;
}
if (!file_exists($snapshot) || $_imageUrlChanged === true) {
require_once 'lib/snapshot.class.php';
$snap = new Snapshot();
- $snap->doSnapshot($this->_data['link']);
+ $do = $snap->doSnapshot($this->_data['link'], $snapshot);
+ if(empty($do)) {
+ error_log('ERROR Failed to create snapshot: '.var_export($data,true));
+ }
}
} elseif ($data['snapshot'] === false) {
if (file_exists($snapshot)) {
$ret = true;
} else {
$this->DB->rollback();
+ error_log('ERROR Failed to update link: '.var_export($data,true));
}
}
* call given url with google PageSpeed API
* to recieve image data
*
- * @param String $url URL to take a screenshot from
+ * @param String $url URL to take a thumbnail from
* @return
*/
- public function doSnapshot($url) {
- if(!empty($url)) {
+ public function doSnapshot($url,$filename) {
+ $ret = false;
+
+ if(!empty($url) && is_writable(dirname($filename))) {
$theCall = Summoner::curlCall($this->_googlePageSpeed.urlencode($url).'&screenshot=true');
- var_dump($theCall);
+ if(!empty($theCall)) {
+ $jsonData = json_decode($theCall,true);
+ if(!empty($jsonData) && isset($jsonData['screenshot']['data'])) {
+ $imageData = $jsonData['screenshot']['data'];
+ $imageData = str_replace(['_', '-'], ['/', '+'], $imageData);
+ $imageData = base64_decode($imageData);
+ $ret = file_put_contents($filename, $imageData);
+ }
+ }
}
- }
- /**
- * save given screenshot data
- *
- * @param $data
- * @return bool
- */
- public function saveScreenshot($data) {}
+ return $ret;
+ }
}
\ No newline at end of file
}
$linkObj = new Link($DB);
-$linkObj->load($_id);
if($_isAwm === true) {
$submitFeedback['message'] = 'To accept this link (link has moderation status), just save it. Otherwise just delete.';
}
if($_requestMode && $_requestMode == "export") {
+ $linkObj->load($_id);
+
$_i = $linkObj->getData('id');
if(!empty($_i)) {
$formData['tag'] = trim($fData['tag']);
if(!empty($formData['title'])) {
+ $linkObj->load($_id);
+
$update = $linkObj->update($formData);
if($update === true) {
</p>
<input class="input" type="text" name="data[image]" value="<?php echo Summoner::ifset($formData, 'image'); ?>" /><br />
<br />
- <input class="checkbox" type="checkbox" name="data[localImage]" value="1" <?php if(Summoner::ifset($formData, 'localImage')) echo "checked"; ?> />
- Store image locally
+ <label class="checkbox">
+ <input type="checkbox" name="data[localImage]" value="1" <?php if(Summoner::ifset($formData, 'localImage')) echo "checked"; ?> />
+ Store image locally
+ </label>
+ </div>
+ </div>
+ <div class="columns">
+ <div class="column is-one-quarter">
+ <p>
+ Thumbnail of the webpage. Not the image provided with html meta data.
+ </p>
+ </div>
+ <div class="column">
+ <?php if(isset($linkData['snapshotLink'])) { ?>
+ <p><a href="<?php echo $linkData['snapshotLink']; ?>" target="_blank">View Thumbnail</a></p>
+ <?php } ?>
+ <label class="checkbox">
+ <input type="checkbox" name="data[snapshot]" value="1" <?php if(Summoner::ifset($formData, 'snapshot')) echo "checked"; ?> />
+ Save a thumbnail (This can take some time)
+ </label>
</div>
</div>
<div class="columns">
<input type="checkbox" name="data[private]" value="1" <?php if(Summoner::ifset($formData, 'private')) echo "checked"; ?> />
Private
</label>
- <label class="checkbox">
- <input type="checkbox" name="data[snapshot]" value="1" <?php if(Summoner::ifset($formData, 'snapshot')) echo "checked"; ?> />
- Save a snapshot (This can take some time)
- </label>
</div>
</div>
<div class="columns">