Skip to content

Commit d8db28f

Browse files
landing page: display first 10 line in description
1 parent 1c04072 commit d8db28f

4 files changed

Lines changed: 26 additions & 1 deletion

File tree

cds/config.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,11 @@ def _parse_env_bool(var_name, default=None):
10841084
"qs": 'q=keywords.name:"VNR" OR keywords.name:"video news release"',
10851085
},
10861086
]
1087+
###############################################################################
1088+
# Record Landing page
1089+
###############################################################################
1090+
1091+
DESCRIPTION_PREVIEW_LINES = 10
10871092

10881093
###############################################################################
10891094
# Security

cds/modules/records/static/templates/cds_records/video/detail.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ <h4>{{translation.title.title}}</h4>
235235
<!-- Date & Views -->
236236
<!-- Description -->
237237
<div ng-init="showFullDescription=false" class="cds-detail-description cds-detail-video-description t-b px-20">
238-
<p class="mb-30" ng-bind-html="(processDescriptionWithClickableTimestamps(record.metadata.description) | trustHtml) || 'No description'"></p>
238+
<p class="mb-30" ng-bind-html="(showFullDescription ? fullDescription : shortDescription | trustHtml) || 'No description'"></p>
239239
<!-- Hidden content -->
240240
<div class="mt-20" ng-show="showFullDescription">
241241
<!-- Contributors -->

cds/modules/records/templates/cds_records/record_detail.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@
100100
record-views="{{ record_view_url }}"
101101
media-download-event-url="{{ user_action_media_download_url }}"
102102
related-query-url="{{ related_query_url }}"
103+
preview-lines="{{ config.DESCRIPTION_PREVIEW_LINES }}"
103104
></cds-record-view>
104105
</div>
105106
<!-- Recent videos -->

cds/modules/theme/assets/bootstrap3/js/cds_records/cdsRecord.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function cdsRecordController($scope, $sce, $http, $timeout, $filter) {
6161
$scope.transcriptSearch = "";
6262
$scope.chapters = [];
6363
$scope.activeTab = "chapters"; // Default to chapters tab
64+
$scope.shortDescription = "";
65+
$scope.fullDescription = "";
6466

6567
const REQUEST_HEADERS = {
6668
"Content-Type": "application/json",
@@ -188,9 +190,24 @@ function cdsRecordController($scope, $sce, $http, $timeout, $filter) {
188190
$scope.$watch("record", function (newVal) {
189191
if (newVal) {
190192
$scope.initVttLoad(newVal);
193+
$scope.prepareDescriptions(newVal.metadata.description);
191194
}
192195
});
193196

197+
$scope.prepareDescriptions = function (description) {
198+
if (!description) {
199+
$scope.shortDescription = "No description";
200+
$scope.fullDescription = "No description";
201+
return;
202+
}
203+
204+
const lines = description.split(/\r?\n/);
205+
const firstTen = lines.slice(0, $scope.DESCRIPTION_PREVIEW_LINES).join("\n");
206+
207+
$scope.shortDescription = $scope.processDescriptionWithClickableTimestamps(firstTen);
208+
$scope.fullDescription = $scope.processDescriptionWithClickableTimestamps(description);
209+
};
210+
194211
$scope.initVttLoad = function (record) {
195212
const files = record.metadata._files || [];
196213

@@ -644,6 +661,8 @@ function cdsRecordView($http) {
644661

645662
scope.relatedQueryUrl = attrs.relatedQueryUrl;
646663

664+
scope.DESCRIPTION_PREVIEW_LINES = parseInt(attrs.previewLines, 10) || 10;
665+
647666
// Get the record object and make it available to the scope
648667
$http.get(attrs.record).then(
649668
function (response) {

0 commit comments

Comments
 (0)