Commit 10d92d42 authored by Étienne Oz's avatar Étienne Oz 🖖

du style et des tests api

parent 2bbd8b41
......@@ -4,8 +4,46 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "a87792389c218b076a3d9c0f086eed7a",
"content-hash": "8301c183f5ec51302692ba1d77580f50",
"packages": [
{
"name": "adibaba/zotero-api-client",
"version": "v0.0.2",
"source": {
"type": "git",
"url": "https://github.com/adibaba/ZoteroApiClient.git",
"reference": "eccd556921d3266d415bf5ae13d6c0e7f5a8f340"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/adibaba/ZoteroApiClient/zipball/eccd556921d3266d415bf5ae13d6c0e7f5a8f340",
"reference": "eccd556921d3266d415bf5ae13d6c0e7f5a8f340",
"shasum": ""
},
"type": "library",
"autoload": {
"psr-4": {
"Adibaba\\ZoteroApiClient\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Adrian Wilke",
"homepage": "https://adrianwilke.de"
}
],
"description": "Zotero API client using cURL",
"keywords": [
"api",
"curl",
"zotero"
],
"time": "2017-09-14T06:18:17+00:00"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.3",
......
<?php
$debug = false;
$debug = true;
?>
......@@ -17,12 +17,10 @@
$allTags = [];
foreach ($items as $item) {
foreach ($item as $data) {
$tags = $data['tags'];
foreach ($tags as $tag) {
if ($tag['tag'] != 'notShowed' && $tag['tag'] != 'cambreOk' && $tag['tag'] != 'pourMoi') {
array_push($allTags, $tag['tag']);
}
$tags = $item['data']['tags'];
foreach ($tags as $tag) {
if ($tag['tag'] != 'notShowed' && $tag['tag'] != 'cambreOk' && $tag['tag'] != 'pourMoi') {
array_push($allTags, $tag['tag']);
}
}
}
......@@ -30,20 +28,22 @@
$allTags = array_unique($allTags);
echo '<ul class="tags">';
echo '<li><h1>Wwwahou</h1></li>';
echo '<li><h1>Wwwahou </h1></li>';
foreach ($allTags as $tag) {
echo '~ <li class="tag">' . $tag . '</li> ';
echo '~ <li class="tag '. $tag .'">' . $tag . '</li> ';
}
echo '</ul>';
foreach ($items as $item) {
foreach ($item as $data) {
if (is_array($data) && in_array('webpage', $data)) {
$title = $data['title'];
$url = $data['url'];
$date = substr($data['dateAdded'], -10);
$abstract = $data['abstractNote'];
$tags = $data['tags'];
$data = $item['data'];
if (is_array($data) && in_array('webpage', $data)) {
$title = $data['title'];
$url = $data['url'];
$date = substr($data['dateAdded'], 0, 10);
$abstract = $data['abstractNote'];
$tags = $data['tags'];
if ($url) {
# code...
echo '<div class="item';
foreach ($tags as $tag) {
if ($tag['tag'] != 'notShowed' && $tag['tag'] != 'cambreOk' && $tag['tag'] != 'pourMoi') {
......@@ -51,16 +51,20 @@
}
}
echo '">';
echo '<sub>' . $date . ' </sub>';
echo '<a href=" ' . $url . ' " target="_blank">' . ($title ? $title : '----') . '</a>';
echo '<sup>';
foreach ($tags as $tag) {
if ($tag['tag'] != 'notShowed' && $tag['tag'] != 'cambreOk' && $tag['tag'] != 'pourMoi') {
echo ' <span>' . $tag['tag'] . '</span>';
echo '<span class="infos">';
echo '<span>' . $date . ' </span>';
echo '<a href=" ' . $url . '" target="_blank">' . ($title ? $title : '----') . '</a>';
echo '<sup>';
foreach ($tags as $tag) {
if ($tag['tag'] != 'notShowed' && $tag['tag'] != 'cambreOk' && $tag['tag'] != 'pourMoi') {
echo ' <span>' . $tag['tag'] . '</span>';
}
}
}
echo '</sup>';
echo '</sup>';
echo '</span>';
echo ' <p>'. $abstract . '</p>';
// echo '<div class="img"><img data-src="'. $url .'" /></div>';
echo '<div class="iframe"><iframe data-src="'. $url .'"></iframe></div>';
echo '</div>';
}
}
......
function loadAndShowIframe(item){
item.children('.infos').children('a').mouseenter(function(){
var iframe = $(this).parents('.item').find('iframe');
var src = iframe.attr('data-src');
iframe.attr('src', src);
iframe.parent('.iframe').show();
iframe.contents().find('audio, video').each(function(){
$(this).volume = 0.0;
});
}).mouseleave(function(){
var iframe = $(this).parents('.item').find('iframe');
var src = iframe.attr('src');
var parent = iframe.parent('.iframe');
iframe.remove();
parent.hide();
parent.append('<iframe data-src="' + src + '"></iframe>')
})
}
function blurItems(item){
item.children('.infos').mouseenter(function(){
$('.item *:not(iframe)').css({'filter': 'blur(1px)'});
var parentItem = $(this).parents('.item');
parentItem.find('*').css({'filter': 'blur(0px)'});
}).mouseleave(function(){
$('.item *:not(iframe)').css({'filter': 'blur(0px)'});
})
}
function showAbstract(item){
item.mouseenter(function(){
$(this).find('p').css({'display': 'inline-block'});
}).mouseleave(function(){
$(this).find('p').hide();
})
}
function classContent(item){
var filter = $('.tags').find('li');
filter.click(function(){
var theClass = $(this).attr('class').split(' ')[1];
if (!$(this).hasClass('beyond')){
$(this).addClass('beyond');
item.removeClass('beyond').addClass('behind');
item.filter('.'+theClass).addClass('beyond').removeClass('behind');
} else {
$(this).removeClass('beyond');
if (!filter.hasClass('beyond')) {
item.removeClass('beyond').removeClass('behind');
} else{
$('.item').find('.'+theClass).removeClass('beyond').addClass('behind');
}
}
})
}
function marginItems(item){
var i = .1;
var j = $(window).width() / 1.5;
item.each(function(){
if (i < $(window).width() / 1.5) {
$(this).css({marginLeft: i + 'px'});
i = i * 1.3;
j = $(window).width() / 1.5;
} else if (j < .1){
i = .1;
$(this).css({marginLeft: i + 'px'});
i = i * 1.3;
} else {
$(this).css({marginLeft: j + 'px'});
j = j / 1.3;
}
})
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
$(document).ready(function(){
var item = $('.item');
loadAndShowIframe(item);
blurItems(item);
showAbstract(item);
classContent(item);
marginItems(item)
})
......@@ -19,26 +19,46 @@ ul li:after{
/* content: ' ~ '; */
}
.item {
transform: skewY(.75deg);
/* transform: skewY(.75deg); */
transform-origin: 0 0;
line-height: 1.25rem;
}
.item .infos{
display: inline-block;
}
.item .infos a{
display: inherit;
}
.item *{
line-height: 1.25rem;
transform: skewX(-10deg);
}
.item:nth-of-type(odd) *{
background: lightyellow;
transform: skewX(10deg);
}
.item.behind{
display: none;
}
p{
display: inline-block;
display: none;
position: absolute;
background: white;
margin: 0;
transform: skewY(-1.5deg);
transform-origin: 0 0;
width: 50%;
vertical-align: top;
z-index: 5;
margin-left: 10px;
padding: 10px;
padding-top: 0;
}
sub{
.item .infos > span{
color: darkgreen;
}
......@@ -46,3 +66,25 @@ sup span{
border: 1px solid;
padding: 0 3px;
}
.iframe{
display: none;
position: fixed;
z-index: 10;
bottom: 10px;
right: 25px;
width: 100vw;
height: 50vw;
transform: scale(.35) skew(0deg) !important;
transform-origin: 100% 100%;
background: white !important;
}
.iframe iframe{
background: white !important;
width: 100%;
height: 100%;
border: 2px solid;
border: 2px solid darkblue;
box-shadow: darkblue 14px -20px 60px -10px;
}
MIT License
Copyright (c) 2017 Adrian Wilke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"autoload" : {
"psr-4" : {
"Adibaba\\ZoteroApiClient\\" : "src"
}
},
"name" : "adibaba/zotero-api-client",
"authors" : [{
"name" : "Adrian Wilke",
"homepage" : "https://adrianwilke.de"
}
],
"description" : "Zotero API client using cURL",
"license" : "MIT",
"keywords" : [
"zotero",
"api",
"curl"
]
}
\ No newline at end of file
<?php
namespace Adibaba\ZoteroApiClient;
/**
* Requests the Zotero API using cURL
*
* @see https://www.zotero.org/support/dev/web_api/v3/start
* @see http://php.net/manual/en/book.curl.php
* @see https://curl.haxx.se/
*
* @author Adrian Wilke
*/
class ZoteroApiCurlRequest
{
/**
* The base URL for all API requests
*
* @var string
*/
const BASE_URL = 'https://api.zotero.org';
/**
* API version 3 [...] is currently the default and recommended version
*
* @var integer
*/
const ZOTERO_API_VERSION = 3;
/**
* Zotero API key for authentication
*
* @var string
*/
private $zoteroApiKey;
/**
* cURL handle
*
* @var resource cURL
*/
private $curlHandle;
/**
* Latest response header
*
* @var string
*/
private $responseHeader;
/**
* Sets Zotero API key.
* End users can create API keys via their Zotero account settings.
* This is not required for read access to public libraries.
*
* @see https://www.zotero.org/settings/keys
*
* @param string $zoteroApiKey
* API key specified in Zotero account settings
*
* @return \Adibaba\ZoteroApiClient\ZoteroApiCurlRequest
*/
public function setZoteroApiKey($zoteroApiKey)
{
$this->zoteroApiKey = $zoteroApiKey;
return $this;
}
/**
* Initializes Zotero API request using cURL
*
* @see https://www.zotero.org/support/dev/web_api/v3/basics
*
* @param string $uri
* URI like specified in documentation
*
* @throws \Exception If URI does not start with slash
*
* @return \Adibaba\ZoteroApiClient\ZoteroApiCurlRequest
*/
public function initialize($uri)
{
// Close handle, if still open (e.g. error handling on failures)
if (is_resource($this->curlHandle)) {
curl_close($this->curlHandle);
}
// URI has to begin with slash.
// Just checking to avoid careless mistakes.
if (substr($uri, 0, 1) !== '/') {
throw new \Exception('URI not valid (no slash)');
}
// Initialize cURL and reset prior response header
$this->curlHandle = curl_init();
$this->responseHeader = '';
// Set the URL to fetch
curl_setopt($this->curlHandle, CURLOPT_URL, self::BASE_URL . $uri);
// An array of HTTP header fields specifying API version and authentication data
$headers = array(
'Zotero-API-Version: ' . self::ZOTERO_API_VERSION
);
// Authentication is not required for read access to public libraries.
if (isset($this->zoteroApiKey)) {
array_push($headers, 'Zotero-API-Key: ' . $this->zoteroApiKey);
}
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers);
// Return the transfer as a string instead of outputting it out directly
curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true);
// The header data must be written by this callback. Return the number of bytes written.
curl_setopt($this->curlHandle, CURLOPT_HEADERFUNCTION, array(
&$this,
'responseHeaderCallback'
));
return $this;
}
/**
* Executes Zotero API request using cURL
*
* @return string|false Returns the result on success, FALSE on failure.
*/
public function execute()
{
// Execute request
$response = curl_exec($this->curlHandle);
// Free all resources.
// For error handling do not close on failure.
if (false !== $response) {
curl_close($this->curlHandle);
}
return $response;
}
/**
* Returns the latest response header
*
* @return string
*/
public function getResponseHeader()
{
return $this->responseHeader;
}
/**
* Returns the cURL handle
*
* @return resource
*/
public function getCurlHandle()
{
return $this->curlHandle;
}
/**
* Set cURL handle.
* This optional function can be used between initializing and executing a request.
*
* @param resource $curlHandle
*/
public function setCurlHandle($curlHandle)
{
$this->curlHandle = $curlHandle;
}
/**
* Callback for header data
*
* @param resource $curlHandle
* cURL resource
* @param string $line
* Header data to be written
* @return number Number of bytes written
*/
protected function responseHeaderCallback($curlHandle, $line)
{
$this->responseHeader .= $line;
return strlen($line);
}
}
\ No newline at end of file
MIT License
Copyright (c) 2017 Adrian Wilke
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
{
"autoload" : {
"psr-4" : {
"Adibaba\\ZoteroApiClient\\" : "src"
}
},
"name" : "adibaba/zotero-api-client",
"authors" : [{
"name" : "Adrian Wilke",
"homepage" : "https://adrianwilke.de"
}
],
"description" : "Zotero API client using cURL",
"license" : "MIT",
"keywords" : [
"zotero",
"api",
"curl"
]
}
\ No newline at end of file
<?php
namespace Adibaba\ZoteroApiClient;
/**
* Requests the Zotero API using cURL
*
* @see https://www.zotero.org/support/dev/web_api/v3/start
* @see http://php.net/manual/en/book.curl.php
* @see https://curl.haxx.se/
*
* @author Adrian Wilke
*/
class ZoteroApiCurlRequest
{
/**
* The base URL for all API requests
*
* @var string
*/
const BASE_URL = 'https://api.zotero.org';
/**
* API version 3 [...] is currently the default and recommended version
*
* @var integer
*/
const ZOTERO_API_VERSION = 3;
/**
* Zotero API key for authentication
*
* @var string
*/
private $zoteroApiKey;
/**
* cURL handle
*
* @var resource cURL
*/
private $curlHandle;
/**
* Latest response header
*
* @var string
*/
private $responseHeader;
/**
* Sets Zotero API key.
* End users can create API keys via their Zotero account settings.
* This is not required for read access to public libraries.
*
* @see https://www.zotero.org/settings/keys
*
* @param string $zoteroApiKey
* API key specified in Zotero account settings
*
* @return \Adibaba\ZoteroApiClient\ZoteroApiCurlRequest
*/
public function setZoteroApiKey($zoteroApiKey)
{
$this->zoteroApiKey = $zoteroApiKey;
return $this;
}
/**
* Initializes Zotero API request using cURL
*
* @see https://www.zotero.org/support/dev/web_api/v3/basics
*
* @param string $uri
* URI like specified in documentation
*
* @throws \Exception If URI does not start with slash
*
* @return \Adibaba\ZoteroApiClient\ZoteroApiCurlRequest
*/
public function initialize($uri)
{
// Close handle, if still open (e.g. error handling on failures)
if (is_resource($this->curlHandle)) {
curl_close($this->curlHandle);
}
// URI has to begin with slash.
// Just checking to avoid careless mistakes.
if (substr($uri, 0, 1) !== '/') {
throw new \Exception('URI not valid (no slash)');
}
// Initialize cURL and reset prior response header
$this->curlHandle = curl_init();
$this->responseHeader = '';
// Set the URL to fetch
curl_setopt($this->curlHandle, CURLOPT_URL, self::BASE_URL . $uri);
// An array of HTTP header fields specifying API version and authentication data
$headers = array(
'Zotero-API-Version: ' . self::ZOTERO_API_VERSION
);
// Authentication is not required for read access to public libraries.
if (isset($this->zoteroApiKey)) {
array_push($headers, 'Zotero-API-Key: ' . $this->zoteroApiKey);
}
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers);
// Return the transfer as a string instead of outputting it out directly
curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, true);
// The header data must be written by this callback. Return the number of bytes written.
curl_setopt($this->curlHandle, CURLOPT_HEADERFUNCTION, array(
&$this,
'responseHeaderCallback'
));
return $this;
}
/**
* Executes Zotero API request using cURL
*
* @return string|false Returns the result on success, FALSE on failure.
*/
public function execute()
{
// Execute request
$response = curl_exec($this->curlHandle);
// Free all resources.
// For error handling do not close on failure.
if (false !== $response) {
curl_close($this->curlHandle);
}
return $response;
}
/**
* Returns the latest response header
*
* @return string