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
5ba495bb
Commit
5ba495bb
authored
Jul 23, 2012
by
Michal Čihař
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add color variants for widget
parent
d421ad80
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
32 deletions
+78
-32
graphics/weblate-widget-black.png
graphics/weblate-widget-black.png
+0
-0
graphics/weblate-widget-white.png
graphics/weblate-widget-white.png
+0
-0
weblate/media/weblate-widget-black.png
weblate/media/weblate-widget-black.png
+0
-0
weblate/media/weblate-widget-grey.png
weblate/media/weblate-widget-grey.png
+0
-0
weblate/media/weblate-widget-white.png
weblate/media/weblate-widget-white.png
+0
-0
weblate/trans/api.py
weblate/trans/api.py
+78
-32
No files found.
graphics/weblate-widget-black.png
0 → 100644
View file @
5ba495bb
1.87 KB
graphics/weblate-widget-white.png
0 → 100644
View file @
5ba495bb
2.56 KB
weblate/media/weblate-widget-black.png
0 → 100644
View file @
5ba495bb
1.87 KB
weblate/media/weblate-widget.png
→
weblate/media/weblate-widget
-grey
.png
View file @
5ba495bb
File moved
weblate/media/weblate-widget-white.png
0 → 100644
View file @
5ba495bb
2.56 KB
weblate/trans/api.py
View file @
5ba495bb
...
...
@@ -122,61 +122,107 @@ def widgets(request, project):
'object'
:
obj
,
}))
@
cache_page
(
3600
)
def
widget_287
(
request
,
project
):
WIDGETS
=
{
'287'
:
{
'default'
:
'grey'
,
'colors'
:
{
'grey'
:
{
'bar'
:
(
0
,
67.0
/
255
,
118.0
/
255
),
'border'
:
(
0
,
0
,
0
),
'text'
:
(
0
,
0
,
0
),
},
'white'
:
{
'bar'
:
(
0
,
67.0
/
255
,
118.0
/
255
),
'border'
:
(
0
,
0
,
0
),
'text'
:
(
0
,
0
,
0
),
},
'black'
:
{
'bar'
:
(
0
,
67.0
/
255
,
118.0
/
255
),
'border'
:
(
255
,
255
,
255
),
'text'
:
(
255
,
255
,
255
),
},
},
'name'
:
'weblate-widget-%(color)s.png'
,
'progress'
:
{
'x'
:
72
,
'y'
:
52
,
'height'
:
6
,
'width'
:
180
,
},
'text'
:
[
{
'text'
:
"%(name)s"
,
'font'
:
(
"Sans"
,
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_NORMAL
),
'font_size'
:
14
,
'pos'
:
(
72
,
19
),
},
{
'text'
:
"translating %(count)d strings into %(languages)d languages"
,
'font'
:
(
"Sans"
,
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_NORMAL
),
'font_size'
:
10
,
'pos'
:
(
72
,
32
),
},
{
'text'
:
'%(percent)d%% complete, help us improve!'
,
'font'
:
(
"Sans"
,
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_NORMAL
),
'font_size'
:
10
,
'pos'
:
(
72
,
44
),
},
],
}
}
#@cache_page(3600)
def
widget_287
(
request
,
project
,
widget
=
'287'
):
obj
=
get_object_or_404
(
Project
,
slug
=
project
)
percent
=
obj
.
get_translated_percent
()
widget_data
=
WIDGETS
[
widget
]
# Get widget color
color
=
request
.
GET
.
get
(
'color'
,
widget_data
[
'default'
])
if
color
not
in
widget_data
[
'colors'
]:
color
=
widget_data
[
'default'
]
response
=
HttpResponse
(
mimetype
=
'image/png'
)
# Background 287 x 66, logo 64 px
surface
=
cairo
.
ImageSurface
.
create_from_png
(
os
.
path
.
join
(
settings
.
WEB_ROOT
,
'media'
,
'weblate-widget.png'
)
os
.
path
.
join
(
settings
.
WEB_ROOT
,
'media'
,
widget_data
[
'name'
]
%
{
'color'
:
color
}
)
)
ctx
=
cairo
.
Context
(
surface
)
# Setup
ctx
.
set_line_width
(
0.2
)
# 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
.
set_source_rgb
(
*
widget_data
[
'colors'
][
color
][
'bar'
]
)
ctx
.
rectangle
(
widget_data
[
'progress'
][
'x'
],
widget_data
[
'progress'
][
'y'
],
widget_data
[
'progress'
][
'width'
]
/
100.0
*
percent
,
widget_data
[
'progress'
][
'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
.
set_source_rgb
(
*
widget_data
[
'colors'
][
color
][
'border'
]
)
ctx
.
rectangle
(
widget_data
[
'progress'
][
'x'
],
widget_data
[
'progress'
][
'y'
],
widget_data
[
'progress'
][
'width'
],
widget_data
[
'progress'
][
'height'
]
)
ctx
.
stroke
()
# Text
ctx
.
set_source_rgb
(
0
,
0
,
0
)
ctx
.
set_source_rgb
(
*
widget_data
[
'colors'
][
color
][
'text'
]
)
ctx
.
new_path
()
ctx
.
move_to
(
p_x
,
19
)
ctx
.
select_font_face
(
"Sans"
,
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_BOLD
)
ctx
.
set_font_size
(
14
)
ctx
.
text_path
(
obj
.
name
)
ctx
.
select_font_face
(
"Sans"
,
cairo
.
FONT_SLANT_NORMAL
,
cairo
.
FONT_WEIGHT_NORMAL
)
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
,
})
for
line
in
widget_data
[
'text'
]:
ctx
.
move_to
(
*
line
[
'pos'
])
ctx
.
select_font_face
(
*
line
[
'font'
])
ctx
.
set_font_size
(
line
[
'font_size'
])
ctx
.
text_path
(
line
[
'text'
]
%
{
'name'
:
obj
.
name
,
'count'
:
obj
.
get_total
(),
'languages'
:
obj
.
get_language_count
(),
'percent'
:
percent
,
})
ctx
.
fill
()
surface
.
write_to_png
(
response
)
...
...
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