Skip to content

Commit

Permalink
add some minor access to archives metadata within front (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
boogheta committed May 26, 2021
1 parent bf95cde commit 70e816d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions hyphe_backend/core.tac
Original file line number Diff line number Diff line change
Expand Up @@ -2818,6 +2818,9 @@ class Memory_Structure(customJSONRPC):
res['size'] = data['size']
res['encoding'] = data.get('encoding')
res['error'] = data.get('error')
res['archive_url'] = data.get('archive_url')
res['archive_date_requested'] = data.get('archive_date_requested')
res['archive_date_obtained'] = data.get('archive_date_obtained')

if include_body and 'body' in data:
res['body'] = unicode(base64.b64encode(data['body']))
Expand Down
15 changes: 11 additions & 4 deletions hyphe_frontend/app/views/webentity.html
Original file line number Diff line number Diff line change
Expand Up @@ -482,10 +482,17 @@ <h3 style="padding: 8px; margin: 0px" ng-if="webentity.pages_total>=1">
<md-list-item
md-virtual-repeat="page in pages | filter:urlSearchQuery:false:url"
>
<a href="{{page.url}}" target="_blank">
<md-tooltip md-direction="left">Open in a new tab</md-tooltip>
<md-icon>link</md-icon>
</a>
<div class="md-primary">
<a href="{{page.url}}" target="_blank">
<md-tooltip md-direction="left">Open in a new tab</md-tooltip>
<md-icon>link</md-icon>
</a>
<br ng-if="page.archive_url" />
<a ng-if="page.archive_url" href="{{page.archive_url}}" target="_blank">
<md-tooltip md-direction="left">Open archived page (from {{ page.archive_date_obtained}}) in a new tab</md-tooltip>
<md-icon>history</md-icon>
</a>
</div>
<div ng-if="page.url===webentity.homepage">
<md-tooltip md-direction="left">Homepage</md-tooltip>
&nbsp;<md-icon>home</md-icon>
Expand Down
4 changes: 4 additions & 0 deletions hyphe_frontend/app/views/webentity.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,15 @@ angular.module('hyphe.webentityController', [])
}
api.getPaginatedPages({
webentityId: $scope.webentity.id
,includePageMetas: true
,token: $scope.pagesToken
}
,function(result){
var pagesBatch = []
result.pages.forEach(function(page){
if (page.archive_url && page.archive_date_obtained) {
page.archive_date_obtained = page.archive_date_obtained.replace(/^(....)(..)(..).*$/, "$1-$2-$3")
}
if (!$scope.webentity.startpages.includes(page.url)) {
pagesBatch.push(page)
} else {
Expand Down
4 changes: 4 additions & 0 deletions hyphe_frontend/app/views/webentity_explorer.html
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ <h3>
<md-tooltip md-direction="left">Open URL in a new tab</md-tooltip>
<md-icon>link</md-icon>
</a>
<a ng-if="item.data.archive_url" href="{{item.data.archive_url}}" target="_blank">
<md-tooltip md-direction="left">Open archived page (from {{ item.archive_date_obtained}}) in a new tab</md-tooltip>
<md-icon>history</md-icon>
</a>
{{ item.label }}
</h3>
<p>Page ({{ item.subtype_explicit }})</p>
Expand Down
2 changes: 2 additions & 0 deletions hyphe_frontend/app/views/webentity_explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ angular.module('hyphe.webentityExplorerController', [])
function loadPages(){
api.getPaginatedPages({
webentityId: $scope.webentity.id
,includePageMetas: true
,token: $scope.pagesToken || null
}
,function(result){
Expand Down Expand Up @@ -492,6 +493,7 @@ angular.module('hyphe.webentityExplorerController', [])
,url: url
,lru: lru
,data: data
,archive_date_obtained: (data.archive_date_obtained || '').replace(/^(....)(..)(..).*$/, "$1-$2-$3")
,isPrefix: isPrefix
,crawled: data.crawled
,subtype: subtype
Expand Down

0 comments on commit 70e816d

Please sign in to comment.