diff --git a/README.rst b/README.rst index 82481df..ef17b8f 100644 --- a/README.rst +++ b/README.rst @@ -50,6 +50,8 @@ Basic usage path('admin/linkcheck/', include('linkcheck.urls')) +#. Run ``./manage.py collectstatic`` if you're deploying your app in production environment. + #. View ``/admin/linkcheck/`` from your browser. We are aware that this documentation is on the brief side of things so any diff --git a/linkcheck/static/linkcheck/css/styles.css b/linkcheck/static/linkcheck/css/styles.css new file mode 100644 index 0000000..8bc4690 --- /dev/null +++ b/linkcheck/static/linkcheck/css/styles.css @@ -0,0 +1,96 @@ + +.objecttype { + width: 99%!important; + margin-bottom: 30px; + border: 0 !important; +} + +.objecttype td { + border: 0; +} + +.module { + width: 100%!important; + border: 0 !important; +} + +.object { + width: 100%!important; + margin: 0; + padding: 35px 0 0 0; +} + +.links { + width: 100%!important; + background-color: white; + border: 1px solid #ddd; + margin: 10px 0 0 0; +} + +.links td, .links tr { + border: 1px solid #ddd; +} + +.links th { + border: 0!important; +} + +td.actioncell { + border-left: 0 !important; + width: 60px !important; +} + +#linkcheck-nav { + width: 100%; + margin-left: auto; + margin-right: auto; + text-align: center; + padding: 10px; +} + +#linkcheck-nav a { + text-decoration: underline; +} + +/* Header Styles */ +.header-cell { + padding: 0; +} + +.header-table-small { + width: 20%; +} + +.header-table-big { + width: 40%; + +} + +.header-report { + display: inline; + padding-left: 5px; +} + +.header-link { + text-decoration: underline; +} + +/* table body styles */ +.emphasis { + font-weight: bold; +} +.coloured-green { + color: green; +} +.coloured-red { + color: red; +} + +/* other styles */ +.current { + margin: 0 25px; +} + +.center-aligned { + text-align: center; +} \ No newline at end of file diff --git a/linkcheck/static/linkcheck/js/script.js b/linkcheck/static/linkcheck/js/script.js new file mode 100644 index 0000000..a39180e --- /dev/null +++ b/linkcheck/static/linkcheck/js/script.js @@ -0,0 +1,55 @@ +function showProgressDots(numberOfDots) { + var progress = document.getElementById('progressDots'); + if (!progress) return; + switch(numberOfDots) { + case 1: + progress.innerHTML = '.  '; + timerHandle = setTimeout(function() { showProgressDots(2); }, 200); + break; + case 2: + progress.innerHTML = '.. '; + timerHandle = setTimeout(function() { showProgressDots(3); }, 200); + break; + case 3: + progress.innerHTML = '...'; + timerHandle = setTimeout(function() { showProgressDots(1); }, 200); + break; + } +} + +$(document).ready(function() { + + const csrfToken = document.querySelector('[name=csrfmiddlewaretoken]').value; + + $(".ignore").submit(function(){ + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + $('tr#link' + data.link).hide('medium'); + var ignored_count = parseInt($('#ignored_count').text()); + ignored_count++; + $('#ignored_count').text(ignored_count); + }); + return false; + }); + + $(".unignore").submit(function(){ + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + $('tr#link' + data.link).hide('medium'); + var ignored_count = parseInt($('#ignored_count').text()); + ignored_count--; + $('#ignored_count').text(ignored_count); + }); + return false; + }); + + $(".recheck").submit(function(){ + $(this).closest('tr').find('td.link_message').html('Checking'); + showProgressDots(1); + $.post(this.action, {'csrfmiddlewaretoken': csrfToken}, (data) => { + var links = data['links']; + for (var link in links) { + $('tr#link'+links[link]).find('td.link_message').text(data['message']).css('color', data['colour']); + } + }); + return false; + }); +}); diff --git a/linkcheck/templates/linkcheck/base_linkcheck.html b/linkcheck/templates/linkcheck/base_linkcheck.html index 03bdcd8..e32de44 100644 --- a/linkcheck/templates/linkcheck/base_linkcheck.html +++ b/linkcheck/templates/linkcheck/base_linkcheck.html @@ -1,8 +1,16 @@ {% extends "admin/change_list.html" %} +{% load static %} {% load i18n %} {% block title %} - {% translate "Link Checker" %} {{ block.super }} + {% translate "Link Checker" %} +{% endblock %} + +{% block extrahead %} + {{ block.super }} + + + {% endblock %} {% block breadcrumbs %} diff --git a/linkcheck/templates/linkcheck/coverage.html b/linkcheck/templates/linkcheck/coverage.html index 0f1c4eb..f0a8954 100644 --- a/linkcheck/templates/linkcheck/coverage.html +++ b/linkcheck/templates/linkcheck/coverage.html @@ -26,10 +26,10 @@ {% for model in coverage_data %} {{ model.name }} - + {{ model.is_covered|yesno:_("Yes,No") }} - + {% if not model.is_covered %} {{ model.suggested_config|render_config }} {% endif %} diff --git a/linkcheck/templates/linkcheck/paginator.html b/linkcheck/templates/linkcheck/paginator.html index d48eb0d..6607806 100644 --- a/linkcheck/templates/linkcheck/paginator.html +++ b/linkcheck/templates/linkcheck/paginator.html @@ -1,5 +1,6 @@ {% load i18n %} -
+ +
{% if pages.number > 1 %} < First @@ -13,7 +14,7 @@ << {% translate "Previous" %} {% endif %} - + {% blocktrans with current=pages.number max=pages.paginator.num_pages %}Page {{ current }} of {{ max }}{% endblocktrans %} diff --git a/linkcheck/templates/linkcheck/report.html b/linkcheck/templates/linkcheck/report.html index 161a968..23b2862 100644 --- a/linkcheck/templates/linkcheck/report.html +++ b/linkcheck/templates/linkcheck/report.html @@ -1,123 +1,6 @@ {% extends "linkcheck/base_linkcheck.html" %} {% load i18n %} {% load linkcheck_model_tags %} -{% block extrahead %} -{{ block.super }} - - - -{% endblock %} {% block innercontent %} @@ -133,17 +16,17 @@ {% for content_type in content_types_list %} -

{{content_type.content_type|get_verbose_name_plural}}

+

{{content_type.content_type|get_verbose_name_plural}}

{% for object in content_type.object_list %}
-

{{report_type}} in '{{object.object}}'

   - {% blocktrans with content_type_name=content_type.content_type.name %}View {{ content_type_name }}{% endblocktrans %}   - {% if object.admin_url %}{% blocktrans with content_type_name=content_type.content_type.name %}Edit {{ content_type_name }}{% endblocktrans %}{% endif %} +

{{report_type}} in '{{object.object}}'

   + {% blocktrans with content_type_name=content_type.content_type.name %}View {{ content_type_name }}{% endblocktrans %}   + {% if object.admin_url %}{% blocktrans with content_type_name=content_type.content_type.name %}Edit {{ content_type_name }}{% endblocktrans %}{% endif %} - - - - + + + + {% for link in object.link_list %} @@ -151,7 +34,7 @@

{{report_type}} in '{{object.obj

- + ' - '' - '', + '' + '', html=True, ) diff --git a/linkcheck/views.py b/linkcheck/views.py index 41de93e..25a8ae2 100644 --- a/linkcheck/views.py +++ b/linkcheck/views.py @@ -150,6 +150,7 @@ def report(request): 'qry_data': rqst.urlencode(), 'report_type': report_type, 'ignored_count': Link.objects.filter(ignore=True).count(), + 'actions_on_top': True, }, ) @@ -169,7 +170,7 @@ def get_status_message(): broken_links = Link.objects.filter(ignore=False, url__status=False).count() if broken_links: return ( - "We've found {} broken link{}.
" + "We've found {} broken link{}.
" "View/fix broken links".format( broken_links, "s" if broken_links > 1 else "", diff --git a/setup.py b/setup.py index 49c3909..0bd6330 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,9 @@ def read(fname): license='BSD', url='https://github.com/DjangoAdminHackers/django-linkcheck', packages=find_packages(), + package_data={ + 'linkcheck': ['static/linkcheck/css/*', 'static/linkcheck/js/*'], + }, include_package_data=True, install_requires=['django>=3.2', 'requests'], extras_require={