2014-03-26 04:41:31 +00:00
/ *
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
Copyright 2014 The Perkeep Authors
2014-03-26 04:41:31 +00:00
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
goog . provide ( 'cam.ImageDetail' ) ;
2014-05-18 19:16:35 +00:00
goog . require ( 'cam.BlobItemVideoContent' ) ;
2014-04-01 02:01:44 +00:00
goog . require ( 'cam.Thumber' ) ;
// Renders the guts of the detail view for images.
2014-03-26 04:41:31 +00:00
cam . ImageDetail = React . createClass ( {
displayName : 'ImageDetail' ,
IMG _MARGIN : 20 ,
2018-06-28 20:11:51 +00:00
KEEPY _WIDTH : 118 ,
KEEPY _HEIGHT : 108 ,
2014-03-26 04:41:31 +00:00
propTypes : {
2014-04-18 02:24:09 +00:00
backwardPiggy : React . PropTypes . bool . isRequired ,
2014-03-26 04:41:31 +00:00
height : React . PropTypes . number . isRequired ,
2014-04-01 02:01:44 +00:00
permanodeMeta : React . PropTypes . object ,
resolvedMeta : React . PropTypes . object . isRequired ,
2014-03-26 04:41:31 +00:00
width : React . PropTypes . number . isRequired ,
} ,
2014-05-18 19:16:35 +00:00
isVideo _ : function ( ) {
return ! this . isImage _ ( ) ;
} ,
isImage _ : function ( ) {
return Boolean ( this . props . resolvedMeta . image ) ;
} ,
2014-03-26 04:41:31 +00:00
componentWillReceiveProps : function ( nextProps ) {
2014-04-01 02:01:44 +00:00
if ( this . props == nextProps || this . props . resolvedMeta . blobRef != nextProps . resolvedMeta . blobRef ) {
2014-05-18 19:16:35 +00:00
this . thumber _ = nextProps . resolvedMeta . image && cam . Thumber . fromImageMeta ( nextProps . resolvedMeta ) ;
2014-03-26 04:41:31 +00:00
this . setState ( { imgHasLoaded : false } ) ;
}
} ,
2014-04-01 02:01:44 +00:00
componentWillMount : function ( ) {
this . componentWillReceiveProps ( this . props , true ) ;
} ,
2014-03-26 04:41:31 +00:00
render : function ( ) {
this . imgSize _ = this . getImgSize _ ( ) ;
2014-12-01 22:01:37 +00:00
return React . DOM . div ( { className : 'detail-view' , style : this . getStyle _ ( ) } ,
2014-03-26 04:41:31 +00:00
this . getImg _ ( ) ,
2014-12-01 22:01:37 +00:00
this . getPiggy _ ( )
) ;
2014-03-26 04:41:31 +00:00
} ,
getSinglePermanodeAttr _ : function ( name ) {
2014-04-01 02:01:44 +00:00
return cam . permanodeUtils . getSingleAttr ( this . props . permanodeMeta . permanode , name ) ;
2014-03-26 04:41:31 +00:00
} ,
onImgLoad _ : function ( ) {
this . setState ( { imgHasLoaded : true } ) ;
} ,
getImg _ : function ( ) {
2017-01-25 17:19:51 +00:00
var transition = React . createElement ( React . addons . TransitionGroup , { transitionName : 'detail-img' } , [ ] ) ;
2014-03-26 04:41:31 +00:00
if ( this . imgSize _ ) {
2014-05-18 19:16:35 +00:00
var ctor = this . props . resolvedMeta . image ? React . DOM . img : React . DOM . video ;
2014-03-26 04:41:31 +00:00
transition . props . children . push (
2014-05-18 19:16:35 +00:00
ctor ( {
2017-01-25 17:19:51 +00:00
className : classNames ( {
2014-03-26 04:41:31 +00:00
'detail-view-img' : true ,
2014-05-18 19:16:35 +00:00
'detail-view-img-loaded' : this . isImage _ ( ) ? this . state . imgHasLoaded : true ,
2014-03-26 04:41:31 +00:00
} ) ,
2014-05-18 19:16:35 +00:00
controls : true ,
2014-03-26 04:41:31 +00:00
// We want each image to have its own node in the DOM so that during the crossfade, we don't see the image jump to the next image's size.
2014-04-18 02:24:09 +00:00
key : 'img' + this . props . resolvedMeta . blobRef ,
2014-05-18 19:16:35 +00:00
onLoad : this . isImage _ ( ) ? this . onImgLoad _ : null ,
src : this . isImage _ ( ) ? this . thumber _ . getSrc ( this . imgSize _ . height ) : './download/' + this . props . resolvedMeta . blobRef + '/' + this . props . resolvedMeta . file . fileName ,
2014-03-26 04:41:31 +00:00
style : this . getCenteredProps _ ( this . imgSize _ . width , this . imgSize _ . height )
} )
) ;
}
return transition ;
} ,
getPiggy _ : function ( ) {
2017-01-25 17:19:51 +00:00
var transition = React . createElement ( React . addons . TransitionGroup , { transitionName : 'detail-piggy' } , [ ] ) ;
2014-05-18 19:16:35 +00:00
if ( this . isImage _ ( ) && ! this . state . imgHasLoaded ) {
2014-03-26 04:41:31 +00:00
transition . props . children . push (
2017-01-25 17:19:51 +00:00
React . createElement ( cam . SpritedAnimation , {
2018-06-28 20:11:51 +00:00
key : 'keepy-sprite' ,
src : 'keepy/keepy-dancing.png' ,
2017-01-25 17:19:51 +00:00
className : classNames ( {
2014-03-26 04:41:31 +00:00
'detail-view-piggy' : true ,
'detail-view-piggy-backward' : this . props . backwardPiggy
} ) ,
2018-06-28 20:11:51 +00:00
numFrames : 12 ,
spriteWidth : this . KEEPY _WIDTH ,
spriteHeight : this . KEEPY _HEIGHT ,
sheetWidth : 6 ,
style : this . getCenteredProps _ ( this . KEEPY _WIDTH , this . KEEPY _HEIGHT )
2014-03-26 04:41:31 +00:00
} ) ) ;
}
return transition ;
} ,
getCenteredProps _ : function ( w , h ) {
2014-08-10 03:17:10 +00:00
var avail = new goog . math . Size ( this . props . width , this . props . height ) ;
2014-03-26 04:41:31 +00:00
return {
top : ( avail . height - h ) / 2 ,
left : ( avail . width - w ) / 2 ,
width : w ,
height : h
}
} ,
getImgSize _ : function ( ) {
2014-05-18 19:16:35 +00:00
if ( this . isVideo _ ( ) ) {
return new goog . math . Size ( this . props . width , this . props . height ) ;
2014-03-26 04:41:31 +00:00
}
2014-04-01 02:01:44 +00:00
var rawSize = new goog . math . Size ( this . props . resolvedMeta . image . width , this . props . resolvedMeta . image . height ) ;
2014-03-26 04:41:31 +00:00
var available = new goog . math . Size (
2014-08-10 03:17:10 +00:00
this . props . width - this . IMG _MARGIN * 2 ,
2014-03-26 04:41:31 +00:00
this . props . height - this . IMG _MARGIN * 2 ) ;
if ( rawSize . height <= available . height && rawSize . width <= available . width ) {
return rawSize ;
}
return rawSize . scaleToFit ( available ) ;
} ,
getStyle _ : function ( ) {
return {
width : this . props . width ,
height : this . props . height
}
} ,
} ) ;
Aspects: A new idea for the detail page.
http://imgur.com/Re14XKc,6fYHJqp,39nnQiT#0
Camlistore is built around the idea that every object is a blob,
but blobs can also self-describe themselves as more than a blob.
For example, some blobs are also files, or images, or sets, or
permanodes, or movies, or foursquare checkins. Etc.
Here is an idea for the detail page that reflects that underlying
reality of Camlistore.
Each blob has a single canonical URL in the web UI for its detail
page. Currently this is /?p=<...>, but should ideally be just
/<blobref>.
Within the web UI, many "aspects" register interest in providing
views on blobs. Each time the user navigates to a detail page,
each aspects gets to say whether it can provide a useful view on
the blob.
Aspects are currently rendered (crappily) as tabs along the bottom
of the UI. I'm not sure how they should actually be rendered, this
is temporary.
This patch includes the following aspects:
- image (the old image detail)
- permanode (the old old permanode page)
- blob (the old old blob page)
Change-Id: Idb3cdbb203799a5d9c113d1b37b67a2724040085
2014-04-14 16:20:22 +00:00
cam . ImageDetail . getAspect = function ( blobref , searchSession ) {
2014-08-10 03:17:10 +00:00
if ( ! blobref ) {
return null ;
}
Aspects: A new idea for the detail page.
http://imgur.com/Re14XKc,6fYHJqp,39nnQiT#0
Camlistore is built around the idea that every object is a blob,
but blobs can also self-describe themselves as more than a blob.
For example, some blobs are also files, or images, or sets, or
permanodes, or movies, or foursquare checkins. Etc.
Here is an idea for the detail page that reflects that underlying
reality of Camlistore.
Each blob has a single canonical URL in the web UI for its detail
page. Currently this is /?p=<...>, but should ideally be just
/<blobref>.
Within the web UI, many "aspects" register interest in providing
views on blobs. Each time the user navigates to a detail page,
each aspects gets to say whether it can provide a useful view on
the blob.
Aspects are currently rendered (crappily) as tabs along the bottom
of the UI. I'm not sure how they should actually be rendered, this
is temporary.
This patch includes the following aspects:
- image (the old image detail)
- permanode (the old old permanode page)
- blob (the old old blob page)
Change-Id: Idb3cdbb203799a5d9c113d1b37b67a2724040085
2014-04-14 16:20:22 +00:00
var rm = searchSession . getResolvedMeta ( blobref ) ;
var pm = searchSession . getMeta ( blobref ) ;
2014-08-10 03:17:10 +00:00
if ( ! pm ) {
return null ;
}
Aspects: A new idea for the detail page.
http://imgur.com/Re14XKc,6fYHJqp,39nnQiT#0
Camlistore is built around the idea that every object is a blob,
but blobs can also self-describe themselves as more than a blob.
For example, some blobs are also files, or images, or sets, or
permanodes, or movies, or foursquare checkins. Etc.
Here is an idea for the detail page that reflects that underlying
reality of Camlistore.
Each blob has a single canonical URL in the web UI for its detail
page. Currently this is /?p=<...>, but should ideally be just
/<blobref>.
Within the web UI, many "aspects" register interest in providing
views on blobs. Each time the user navigates to a detail page,
each aspects gets to say whether it can provide a useful view on
the blob.
Aspects are currently rendered (crappily) as tabs along the bottom
of the UI. I'm not sure how they should actually be rendered, this
is temporary.
This patch includes the following aspects:
- image (the old image detail)
- permanode (the old old permanode page)
- blob (the old old blob page)
Change-Id: Idb3cdbb203799a5d9c113d1b37b67a2724040085
2014-04-14 16:20:22 +00:00
if ( pm . camliType != 'permanode' ) {
pm = null ;
}
// We don't handle camliContentImage like BlobItemImage.getHandler does because that only tells us what image to display in the search results. It doesn't actually make the permanode an image or anything.
2014-08-15 06:04:37 +00:00
if ( rm && ( rm . image || cam . BlobItemVideoContent . isVideo ( rm ) ) ) {
return {
fragment : 'image' ,
title : 'Image' ,
2015-04-02 12:19:20 +00:00
createContent : function ( size , backwardPiggy ) {
2017-01-25 17:19:51 +00:00
return React . createElement ( cam . ImageDetail , {
2015-04-02 12:19:20 +00:00
backwardPiggy : backwardPiggy ,
2014-08-15 06:04:37 +00:00
key : 'image' ,
height : size . height ,
permanodeMeta : pm ,
resolvedMeta : rm ,
width : size . width ,
} ) ;
} ,
} ;
} else {
return null ;
}
Aspects: A new idea for the detail page.
http://imgur.com/Re14XKc,6fYHJqp,39nnQiT#0
Camlistore is built around the idea that every object is a blob,
but blobs can also self-describe themselves as more than a blob.
For example, some blobs are also files, or images, or sets, or
permanodes, or movies, or foursquare checkins. Etc.
Here is an idea for the detail page that reflects that underlying
reality of Camlistore.
Each blob has a single canonical URL in the web UI for its detail
page. Currently this is /?p=<...>, but should ideally be just
/<blobref>.
Within the web UI, many "aspects" register interest in providing
views on blobs. Each time the user navigates to a detail page,
each aspects gets to say whether it can provide a useful view on
the blob.
Aspects are currently rendered (crappily) as tabs along the bottom
of the UI. I'm not sure how they should actually be rendered, this
is temporary.
This patch includes the following aspects:
- image (the old image detail)
- permanode (the old old permanode page)
- blob (the old old blob page)
Change-Id: Idb3cdbb203799a5d9c113d1b37b67a2724040085
2014-04-14 16:20:22 +00:00
} ;