Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/swh/web/assets/src/bundles/webapp/webapp-utils.js b/swh/web/assets/src/bundles/webapp/webapp-utils.js
index 3eba16c3..51c72d7b 100644
--- a/swh/web/assets/src/bundles/webapp/webapp-utils.js
+++ b/swh/web/assets/src/bundles/webapp/webapp-utils.js
@@ -1,266 +1,269 @@
/**
* Copyright (C) 2018-2019 The Software Heritage developers
* See the AUTHORS file at the top-level directory of this distribution
* License: GNU Affero General Public License version 3, or any later version
* See top-level LICENSE file for more information
*/
import objectFitImages from 'object-fit-images';
import {Layout} from 'admin-lte';
import {selectText} from 'utils/functions';
import {BREAKPOINT_MD} from 'utils/constants';
let collapseSidebar = false;
let previousSidebarState = localStorage.getItem('swh-sidebar-collapsed');
if (previousSidebarState !== undefined) {
collapseSidebar = JSON.parse(previousSidebarState);
}
// adapt implementation of fixLayoutHeight from admin-lte
Layout.prototype.fixLayoutHeight = () => {
let heights = {
window: $(window).height(),
header: $('.main-header').outerHeight(),
footer: $('.footer').outerHeight(),
sidebar: $('.main-sidebar').height(),
topbar: $('.swh-top-bar').height()
};
let offset = 10;
$('.content-wrapper').css('min-height', heights.window - heights.topbar - heights.header - heights.footer - offset);
$('.main-sidebar').css('min-height', heights.window - heights.topbar - heights.header - heights.footer - offset);
};
$(document).on('DOMContentLoaded', () => {
// set state to collapsed on smaller devices
if ($(window).width() < BREAKPOINT_MD) {
collapseSidebar = true;
}
// restore previous sidebar state (collapsed/expanded)
if (collapseSidebar) {
// hack to avoid animated transition for collapsing sidebar
// when loading a page
let sidebarTransition = $('.main-sidebar, .main-sidebar:before').css('transition');
let sidebarEltsTransition = $('.sidebar .nav-link p, .main-sidebar .brand-text, .sidebar .user-panel .info').css('transition');
$('.main-sidebar, .main-sidebar:before').css('transition', 'none');
$('.sidebar .nav-link p, .main-sidebar .brand-text, .sidebar .user-panel .info').css('transition', 'none');
$('body').addClass('sidebar-collapse');
$('.swh-words-logo-swh').css('visibility', 'visible');
// restore transitions for user navigation
setTimeout(() => {
$('.main-sidebar, .main-sidebar:before').css('transition', sidebarTransition);
$('.sidebar .nav-link p, .main-sidebar .brand-text, .sidebar .user-panel .info').css('transition', sidebarEltsTransition);
});
}
});
$(document).on('collapsed.lte.pushmenu', event => {
if ($('body').width() >= BREAKPOINT_MD) {
$('.swh-words-logo-swh').css('visibility', 'visible');
}
});
$(document).on('shown.lte.pushmenu', event => {
$('.swh-words-logo-swh').css('visibility', 'hidden');
});
function ensureNoFooterOverflow() {
$('body').css('padding-bottom', $('footer').outerHeight() + 'px');
}
$(document).ready(() => {
// redirect to last browse page if any when clicking on the 'Browse' entry
// in the sidebar
$(`.swh-browse-link`).click(event => {
let lastBrowsePage = sessionStorage.getItem('last-browse-page');
if (lastBrowsePage) {
event.preventDefault();
window.location = lastBrowsePage;
}
});
// ensure footer do not overflow main content for mobile devices
// or after resizing the browser window
ensureNoFooterOverflow();
$(window).resize(function() {
ensureNoFooterOverflow();
if ($('body').hasClass('sidebar-collapse') && $('body').width() >= BREAKPOINT_MD) {
$('.swh-words-logo-swh').css('visibility', 'visible');
}
});
// activate css polyfill 'object-fit: contain' in old browsers
objectFitImages();
// reparent the modals to the top navigation div in order to be able
// to display them
$('.swh-browse-top-navigation').append($('.modal'));
let selectedCode = null;
function getCodeOrPreEltUnderPointer(e) {
let elts = document.elementsFromPoint(e.clientX, e.clientY);
for (let elt of elts) {
if (elt.nodeName === 'CODE' || elt.nodeName === 'PRE') {
return elt;
}
}
return null;
}
// click handler to set focus on code block for copy
$(document).click(e => {
selectedCode = getCodeOrPreEltUnderPointer(e);
});
function selectCode(event, selectedCode) {
if (selectedCode) {
let hljsLnCodeElts = $(selectedCode).find('.hljs-ln-code');
if (hljsLnCodeElts.length) {
selectText(hljsLnCodeElts[0], hljsLnCodeElts[hljsLnCodeElts.length - 1]);
} else {
selectText(selectedCode.firstChild, selectedCode.lastChild);
}
event.preventDefault();
}
}
// select the whole text of focused code block when user
// double clicks or hits Ctrl+A
$(document).dblclick(e => {
if ((e.ctrlKey || e.metaKey)) {
selectCode(e, getCodeOrPreEltUnderPointer(e));
}
});
$(document).keydown(e => {
if ((e.ctrlKey || e.metaKey) && e.key === 'a') {
selectCode(e, selectedCode);
}
});
// show/hide back-to-top button
let scrollThreshold = 0;
scrollThreshold += $('.swh-top-bar').height() || 0;
scrollThreshold += $('.navbar').height() || 0;
$(window).scroll(() => {
if ($(window).scrollTop() > scrollThreshold) {
$('#back-to-top').css('display', 'block');
} else {
$('#back-to-top').css('display', 'none');
}
});
});
export function initPage(page) {
$(document).ready(() => {
// set relevant sidebar link to page active
$(`.swh-${page}-item`).addClass('active');
$(`.swh-${page}-link`).addClass('active');
// triggered when unloading the current page
$(window).on('unload', () => {
// backup sidebar state (collapsed/expanded)
let sidebarCollapsed = $('body').hasClass('sidebar-collapse');
localStorage.setItem('swh-sidebar-collapsed', JSON.stringify(sidebarCollapsed));
// backup current browse page
if (page === 'browse') {
sessionStorage.setItem('last-browse-page', window.location);
}
});
});
}
export function initHomePage() {
$(document).ready(() => {
$('.swh-coverage-list').iFrameResize({heightCalculationMethod: 'taggedElement'});
fetch(Urls.stat_counters())
.then(response => response.json())
.then(data => {
if (data.stat_counters) {
- $('#nb-files').html(data.stat_counters.content.toLocaleString());
- $('#nb-commits').html(data.stat_counters.revision.toLocaleString());
- $('#nb-projects').html(data.stat_counters.origin.toLocaleString());
+ $('#swh-contents-count').html(data.stat_counters.content.toLocaleString());
+ $('#swh-revisions-count').html(data.stat_counters.revision.toLocaleString());
+ $('#swh-origins-count').html(data.stat_counters.origin.toLocaleString());
+ $('#swh-directories-count').html(data.stat_counters.directory.toLocaleString());
+ $('#swh-persons-count').html(data.stat_counters.person.toLocaleString());
+ $('#swh-releases-count').html(data.stat_counters.release.toLocaleString());
}
if (data.stat_counters_history) {
- swh.webapp.drawHistoryCounterGraph('#nb-files-history', data.stat_counters_history.content);
- swh.webapp.drawHistoryCounterGraph('#nb-commits-history', data.stat_counters_history.revision);
- swh.webapp.drawHistoryCounterGraph('#nb-projects-history', data.stat_counters_history.origin);
+ swh.webapp.drawHistoryCounterGraph('#swh-contents-count-history', data.stat_counters_history.content);
+ swh.webapp.drawHistoryCounterGraph('#swh-revisions-count-history', data.stat_counters_history.revision);
+ swh.webapp.drawHistoryCounterGraph('#swh-origins-count-history', data.stat_counters_history.origin);
}
});
});
initPage('home');
}
export function showModalMessage(title, message) {
$('#swh-web-modal-message .modal-title').text(title);
$('#swh-web-modal-message .modal-content p').text(message);
$('#swh-web-modal-message').modal('show');
}
export function showModalConfirm(title, message, callback) {
$('#swh-web-modal-confirm .modal-title').text(title);
$('#swh-web-modal-confirm .modal-content p').text(message);
$('#swh-web-modal-confirm #swh-web-modal-confirm-ok-btn').bind('click', () => {
callback();
$('#swh-web-modal-confirm').modal('hide');
$('#swh-web-modal-confirm #swh-web-modal-confirm-ok-btn').unbind('click');
});
$('#swh-web-modal-confirm').modal('show');
}
export function addJumpToPagePopoverToDataTable(dataTableElt) {
dataTableElt.on('draw.dt', function() {
$('.paginate_button.disabled').css('cursor', 'pointer');
$('.paginate_button.disabled').on('click', event => {
const pageInfo = dataTableElt.page.info();
let content = '<select class="jump-to-page">';
for (let i = 1; i <= pageInfo.pages; ++i) {
let selected = '';
if (i === pageInfo.page + 1) {
selected = 'selected';
}
content += `<option value="${i}" ${selected}>${i}</option>`;
}
content += `</select><span> / ${pageInfo.pages}</span>`;
$(event.target).popover({
'title': 'Jump to page',
'content': content,
'html': true,
'placement': 'top',
'sanitizeFn': swh.webapp.filterXSS
});
$(event.target).popover('show');
$('.jump-to-page').on('change', function() {
$('.paginate_button.disabled').popover('hide');
const pageNumber = parseInt($(this).val()) - 1;
dataTableElt.page(pageNumber).draw('page');
});
});
});
dataTableElt.on('preXhr.dt', () => {
$('.paginate_button.disabled').popover('hide');
});
}
let swhObjectIcons;
export function setSwhObjectIcons(icons) {
swhObjectIcons = icons;
}
export function getSwhObjectIcon(swhObjectType) {
return swhObjectIcons[swhObjectType];
}
let browsedSwhObjectMetadata = {};
export function setBrowsedSwhObjectMetadata(metadata) {
browsedSwhObjectMetadata = metadata;
}
export function getBrowsedSwhObjectMetadata() {
return browsedSwhObjectMetadata;
}
diff --git a/swh/web/templates/homepage.html b/swh/web/templates/homepage.html
index ecedd4dc..d6219c70 100644
--- a/swh/web/templates/homepage.html
+++ b/swh/web/templates/homepage.html
@@ -1,105 +1,120 @@
{% extends "layout.html" %}
{% comment %}
Copyright (C) 2017-2019 The Software Heritage developers
See the AUTHORS file at the top-level directory of this distribution
License: GNU Affero General Public License version 3, or any later version
See top-level LICENSE file for more information
{% endcomment %}
{% load static %}
{% block title %}Welcome to the Software Heritage archive{% endblock %}
{% block navbar-content %}
<h4>Welcome to the Software Heritage archive</h4>
{% endblock %}
{% block content %}
<h4>Overview</h4>
<p>
The long term goal of the Software Heritage initiative is to <strong>collect</strong>
all publicly available software in source code form together with its
development history, replicate it massively to ensure its <strong>preservation</strong>,
and <strong>share</strong> it with everyone who needs it.
The Software Heritage archive is growing over time as we crawl new source code from software
projects and development forges. We will incrementally release archive search
and browse functionalities — as of now you can check whether source code you care
about is already present in the archive or not.
</p>
<p>
<div class="row">
<div class="col-md-4 swh-web-app-link" align="center">
<a href="{% url 'browse-search' %}">
<img alt="Browse the Software Heritage archive" src="{% static 'img/swh-browse.png' %}"/>
<h5>Browse</h5>
<p>Explore the archive using a dedicated web interface.</p>
</a>
</div>
<div class="col-md-4 swh-web-app-link" align="center">
<a href="{% url 'api-1-homepage' %}">
<img alt="Software Heritage Web API" src="{% static 'img/swh-api.png' %}"/>
<h5>Web API</h5>
<p>Query the archive programmatically using a RESTful API.</p>
</a>
</div>
<div class="col-md-4 swh-web-app-link" align="center">
<a href="https://softwareheritage.org/support">
<img alt="Support Software Heritage" src="{% static 'img/swh-support.png' %}"/>
<h5>Support</h5>
<p>You can help build the Great Library of Source Code!</p>
</a>
</div>
</div>
</p>
<h4>Content</h4>
<p>
A significant amount of source code has already been ingested in the Software Heritage
archive. It currently includes:
</p>
<iframe class="swh-coverage-list" src="{% url 'swh-coverage' %}"></iframe>
<h4>Size</h4>
<p>
As of today the archive already contains and keeps safe for you the following amount
of objects:
<div class="row">
<div class="col-md-4" align="center">
<h5>Source files</h5>
- <span id="nb-files" class="swh-counter"></span>
- <div class='d3-wrapper' id="nb-files-history"></div>
+ <span id="swh-contents-count" class="swh-counter"></span>
+ <div class='d3-wrapper' id="swh-contents-count-history"></div>
</div>
<div class="col-md-4 swh-counter-container" align="center">
<h5>Commits</h5>
- <span id="nb-commits" class="swh-counter"></span>
- <div class='d3-wrapper' id="nb-commits-history"></div>
+ <span id="swh-revisions-count" class="swh-counter"></span>
+ <div class='d3-wrapper' id="swh-revisions-count-history"></div>
</div>
<div class="col-md-4 swh-counter-container" align="center">
<h5>Projects</h5>
- <span id="nb-projects" class="swh-counter"></span>
- <div class='d3-wrapper' id="nb-projects-history"></div>
+ <span id="swh-origins-count" class="swh-counter"></span>
+ <div class='d3-wrapper' id="swh-origins-count-history"></div>
+ </div>
+ </div>
+
+ <div class="row mt-3">
+ <div class="col-md-4" align="center">
+ <h5>Directories</h5>
+ <span id="swh-directories-count" class="swh-counter"></span>
+ </div>
+ <div class="col-md-4 swh-counter-container" align="center">
+ <h5>Authors</h5>
+ <span id="swh-persons-count" class="swh-counter"></span>
+ </div>
+ <div class="col-md-4 swh-counter-container" align="center">
+ <h5>Releases</h5>
+ <span id="swh-releases-count" class="swh-counter"></span>
</div>
</div>
<p class="mt-3" style="font-size: 13px">
Note: the counters and graphs above are based on heuristics that might not reflect the exact
size of the archive. While the long-term trends shown and ballpark figures are reliable,
individual point-in-time values might not be.
</p>
</p>
<script>
swh.webapp.initHomePage();
</script>
{% endblock %}

File Metadata

Mime Type
text/x-diff
Expires
Jul 4 2025, 7:55 AM (10 w, 2 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3351843

Event Timeline