Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
converse.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
converse.js
Commits
25fd929c
Commit
25fd929c
authored
Jul 10, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Initial implementation of promotional widget (issue #72)
parent
efe4729e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
155 additions
and
0 deletions
+155
-0
graphics/weblate-widget.png
graphics/weblate-widget.png
+0
-0
graphics/weblate-widget.svg
graphics/weblate-widget.svg
+96
-0
weblate/trans/api.py
weblate/trans/api.py
+57
-0
weblate/urls.py
weblate/urls.py
+2
-0
No files found.
graphics/weblate-widget.png
0 → 100644
View file @
25fd929c
2.52 KB
graphics/weblate-widget.svg
0 → 100644
View file @
25fd929c
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc=
"http://purl.org/dc/elements/1.1/"
xmlns:cc=
"http://creativecommons.org/ns#"
xmlns:rdf=
"http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg=
"http://www.w3.org/2000/svg"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:sodipodi=
"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape=
"http://www.inkscape.org/namespaces/inkscape"
width=
"600"
height=
"138"
id=
"svg2"
inkscape:label=
"Weblate logo"
version=
"1.1"
inkscape:version=
"0.48.3.1 r9886"
sodipodi:docname=
"weblate-widget.svg"
inkscape:export-filename=
"/home/nijel/work/weblate/graphics/weblate-widget.png"
inkscape:export-xdpi=
"43.695652"
inkscape:export-ydpi=
"43.695652"
>
<defs
id=
"defs3"
/>
<sodipodi:namedview
id=
"base"
pagecolor=
"#ffffff"
bordercolor=
"#666666"
borderopacity=
"1.0"
inkscape:pageopacity=
"0.0"
inkscape:pageshadow=
"2"
inkscape:zoom=
"1.5116666"
inkscape:cx=
"300.00001"
inkscape:cy=
"69.500003"
inkscape:document-units=
"px"
inkscape:current-layer=
"layer2"
showgrid=
"false"
inkscape:window-width=
"1364"
inkscape:window-height=
"716"
inkscape:window-x=
"0"
inkscape:window-y=
"27"
inkscape:window-maximized=
"0"
/>
<metadata
id=
"metadata6"
>
<rdf:RDF>
<cc:Work
rdf:about=
""
>
<dc:format>
image/svg+xml
</dc:format>
<dc:type
rdf:resource=
"http://purl.org/dc/dcmitype/StillImage"
/>
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:groupmode=
"layer"
id=
"layer2"
inkscape:label=
"Background"
style=
"display:inline"
>
<rect
style=
"fill:#e6e6e6;stroke:#808080;stroke-width:0.99555939"
id=
"rect2989"
width=
"599.00446"
height=
"137.00444"
x=
"0.4977797"
y=
"0.49777371"
/>
</g>
<g
inkscape:label=
"Vrstva 1"
inkscape:groupmode=
"layer"
id=
"layer1"
transform=
"translate(0,-914.36218)"
style=
"display:inline"
>
<text
xml:space=
"preserve"
style=
"font-size:100px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#cc0000;fill-opacity:1;stroke:none;font-family:cmmi10;-inkscape-font-specification:cmmi10"
x=
"7.8958373"
y=
"995.98053"
id=
"text2992"
sodipodi:linespacing=
"125%"
><tspan
sodipodi:role=
"line"
id=
"tspan2994"
x=
"7.8958373"
y=
"995.98053"
>
W
</tspan></text>
<text
xml:space=
"preserve"
style=
"font-size:100px;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#004276;fill-opacity:1;stroke:none;font-family:cmmi10;-inkscape-font-specification:cmmi10"
x=
"66.692131"
y=
"1039.4989"
id=
"text2996"
sodipodi:linespacing=
"125%"
><tspan
sodipodi:role=
"line"
id=
"tspan2998"
x=
"66.692131"
y=
"1039.4989"
>
L
</tspan></text>
</g>
</svg>
weblate/trans/api.py
View file @
25fd929c
...
...
@@ -9,6 +9,7 @@ from weblate.trans.models import Project, SubProject
import
json
import
logging
import
threading
import
cairo
logger
=
logging
.
getLogger
(
'weblate'
)
...
...
@@ -93,3 +94,59 @@ def export_stats(request, project, subproject):
json
.
dumps
(
response
,
default
=
dt_handler
),
mimetype
=
'application/json'
)
def
widget_287
(
request
,
project
):
obj
=
get_object_or_404
(
Project
,
slug
=
project
)
percent
=
obj
.
get_translated_percent
()
response
=
HttpResponse
(
mimetype
=
'image/png'
)
# Background 287 x 66, logo 64 px
surface
=
cairo
.
ImageSurface
.
create_from_png
(
'/home/nijel/work/weblate/graphics/weblate-widget.png'
)
ctx
=
cairo
.
Context
(
surface
)
# Setup
ctx
.
set_line_width
(
0.2
)
ctx
.
select_font_face
(
"Sans"
)
ctx
.
set_font_size
(
14
)
# Progressbar params
p_x
=
72
p_y
=
52
p_height
=
6
p_width
=
180
# Progress bar
ctx
.
new_path
()
ctx
.
set_source_rgb
(
0
,
67.0
/
255
,
118.0
/
255
)
ctx
.
rectangle
(
p_x
,
p_y
,
p_width
/
100.0
*
percent
,
p_height
)
ctx
.
fill
()
# Progress border
ctx
.
new_path
()
ctx
.
set_source_rgb
(
0
,
0
,
0
)
ctx
.
rectangle
(
p_x
,
p_y
,
p_width
,
p_height
)
ctx
.
stroke
()
# Text
ctx
.
set_source_rgb
(
0
,
0
,
0
)
ctx
.
new_path
()
ctx
.
move_to
(
p_x
,
19
)
ctx
.
text_path
(
obj
.
name
)
ctx
.
set_font_size
(
10
)
ctx
.
move_to
(
p_x
,
32
)
ctx
.
text_path
(
"translating %(count)d strings into %(languages)d languages"
%
{
'count'
:
obj
.
get_total
(),
'languages'
:
obj
.
get_language_count
(),
'percent'
:
percent
,
})
ctx
.
move_to
(
p_x
,
44
)
ctx
.
text_path
(
'%(percent)d%% complete, help us improve!'
%
{
'count'
:
obj
.
get_total
(),
'languages'
:
obj
.
get_language_count
(),
'percent'
:
percent
,
})
ctx
.
fill
()
surface
.
write_to_png
(
response
)
return
response
weblate/urls.py
View file @
25fd929c
...
...
@@ -65,6 +65,8 @@ urlpatterns = patterns('',
url
(
r'^exports/stats/(?P<project>[^/]*)/(?P<subproject>[^/]*)/$'
,
'weblate.trans.api.export_stats'
),
url
(
r'^widgets/(?P<project>[^/]*)/287x66/$'
,
'weblate.trans.api.widget_287'
),
url
(
r'^js/get/(?P<checksum>[^/]*)/$'
,
'weblate.trans.views.get_string'
),
url
(
r'^js/ignore-check/(?P<check_id>[0-9]*)/$'
,
'weblate.trans.views.ignore_check'
),
url
(
r'^js/i18n/$'
,
'django.views.i18n.javascript_catalog'
,
js_info_dict
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment