Skip to content

Commit

Permalink
show license details
Browse files Browse the repository at this point in the history
  • Loading branch information
t-8ch committed Dec 16, 2015
1 parent 233e178 commit ac111e4
Show file tree
Hide file tree
Showing 41 changed files with 1,833 additions and 5 deletions.
1 change: 1 addition & 0 deletions oscad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def main(global_config, **settings):
config.add_route('about', 'about')
config.add_route('help', 'help')
config.add_route('components', 'components')
config.add_route('license', 'license/{license}')
config.add_route('change_language', 'language/{lang}')
config.add_route('translation_template', 'translations/oscad.pot')
config.add_route('translation_file', 'translations/{lang}')
Expand Down
7 changes: 7 additions & 0 deletions oscad/templates/oscad/baserequest.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
</a>
{%- endmacro -%}

{%- macro license_link(id) -%}
<a href="{{ request.route_path('license', license=id) }}"
title="{{ license_details[id].name }}">
{{ id }}
</a>
{%- endmacro -%}

{%- block content -%}
<div class="row">
<div class="col-md-offset-1 col-md-10">
Expand Down
13 changes: 13 additions & 0 deletions oscad/templates/oscad/license.jinja2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{%- extends 'base.jinja2' -%}

{%- block content -%}

<h1>License: {{ name }}</h1>

<p>
<pre>
{{ text }}
</pre>
</p>

{%- endblock -%}
4 changes: 2 additions & 2 deletions oscad/templates/oscad/matrix.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<input type="radio" name="license" value="{{ license }}"
{%- if license == default_license
%} checked="checked" {%- endif %} />
{{ license }}
{{ license_link(license) }}
</label>
</li>
{%- endfor -%}
Expand All @@ -64,8 +64,8 @@
<label>
<input type="radio" name="license" value="{{ license }}"
disabled="disabled" />
{{ license }}
</label>
{{ license_link(license) }}
</li>
{%- endfor -%}
</ul>
Expand Down
4 changes: 2 additions & 2 deletions oscad/templates/oscad/request.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
{%- if license == default_license
%} checked="checked" {%- endif %}
/>
{{ license }}
{{ license_link(license) }}
</label>
</li>
{%- endfor -%}
Expand All @@ -99,7 +99,7 @@
<li class="radio">
<label>
<input type="radio" name="license" disabled="disabled" />
{{ license }}
{{ license_link(license) }}
</label>
</li>
{%- endfor -%}
Expand Down
16 changes: 16 additions & 0 deletions oscad/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def index(request):
def request(request):
return {
'licenses': data.valid_licenses,
'license_details': data.license_details,
'default_license': DEFAULT_LICENSE,
'planned_licenses': PLANNED_LICENSES,
}
Expand All @@ -111,6 +112,20 @@ def about(request):
}


@view_config(route_name='license', renderer='templates/oscad/license.jinja2')
def license(request):
slug = request.matchdict['license']
info = data.license_details[slug]
name = info['name']
text = info['text']

return {
'slug': slug,
'name': name,
'text': text,
}


@view_config(route_name='components',
renderer='templates/oscad/components.jinja2')
def components(request):
Expand Down Expand Up @@ -201,6 +216,7 @@ def matrix_request(request):
return {
'table': data.license_matrix(),
'licenses': data.valid_licenses,
'license_details': data.license_details,
'default_license': DEFAULT_LICENSE,
'planned_licenses': PLANNED_LICENSES,
}
Expand Down
8 changes: 7 additions & 1 deletion oscad_data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pkg_resources import resource_stream, resource_string

import yaml
from pkg_resources import resource_stream


def load_data(name):
Expand All @@ -14,6 +15,7 @@ def load_file(fileobj):
licensenames = load_data('licensenames')
osuc = load_data('osuc')
lsuc = load_data('lsuc')
license_details = load_data('license_details')

attrs = [
('recipients', 'recipient'),
Expand All @@ -33,6 +35,10 @@ def load_file(fileobj):

valid_inputs['license'] = valid_licenses

for id, details in license_details.items():
details['text'] = resource_string(
__name__, 'data/texts/{}.txt'.format(id)).decode('utf-8')


# generate from sources
def license_matrix():
Expand Down
51 changes: 51 additions & 0 deletions oscad_data/data/license_details.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
AGPLv3.0:
name: "GNU Affero General Public License 3.0"
licensedb_id: AGPL-3.0
ApLv2.0:
name: "Apache License 2.0"
licensedb_id: Apache-2.0
BSDv2CL:
name: 'BSD 2-Clause "Simplified" or "FreeBSD" License'
licensedb_id: BSD-2-Clause
BSDv3CL:
name: 'BSD 3-Clause "New" or "Revised" License'
licensedb_id: BSD-3-Clause
CDDLv1.0:
name: "Common Development and Distribution License 1.0"
licensedb_id: CDDL-1.0
EPLv1.0:
name: "Eclipse Public License 1.0"
licensedb_id: EPL-1.0
EUPLv1.1:
name: "European Union Public License, Version 1.1"
licensedb_id: EUPL-1.1
GPLv2.0:
name: "GNU General Public License version 2.0"
licensedb_id: GPL-2.0
GPLv3.0:
name: "GNU General Public License version 3.0"
licensedb_id: GPL-3.0
LGPLv2.1:
name: 'GNU Library or "Lesser" General Public License version 2.1'
licensedb_id: LGPL-2.1
LGPLv3.0:
name: 'GNU Library or "Lesser" General Public License version 3.0'
licensedb_id: LGPL-3.0
MIT:
name: "MIT license"
licensedb_id: MIT
MPLv2.0:
name: "Mozilla Public License 2.0"
licensedb_id: MPL-2.0
MS-PL:
name: "Microsoft Public License"
licensedb_id: MS-PL
PGL:
name: "The PostgreSQL License"
licensedb_id: PostgreSQL
PHPv3.0:
name: "PHP License 3.0"
licensedb_id: PHP-3.0
ZLIB:
name: "zlib/libpng license"
licensedb_id: Zlib
Loading

0 comments on commit ac111e4

Please sign in to comment.