added: two tables to locales/substitute: smallleters, capitalics

added: locale.ToSmall(wchar_t), locale.ToCapital(wchar_t)
       now we are able to recognize other than ASCII characters
added: static/basic/winix.css with basic styles
removed: [include "item_options.html"] from html templates (fun_cat.html and others)




git-svn-id: svn://ttmath.org/publicrep/winix/trunk@760 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
Tomasz Sowa 2011-08-29 22:23:54 +00:00
parent b984475e49
commit 8c01b0f6c0
10 changed files with 626 additions and 54 deletions

View File

@ -343,7 +343,7 @@ std::wstring::iterator i;
{
if( !CorrectUrlChar(*i) )
{
wchar_t c = TemplatesFunctions::locale.Subst(*i);
wchar_t c = TemplatesFunctions::locale.UrlSubst(*i);
if( CorrectUrlChar(c) )
*i = c;

View File

@ -34,7 +34,4 @@
[include "item_options.html"]

View File

@ -77,5 +77,3 @@
[end]
[include "item_options.html"]

View File

@ -96,7 +96,6 @@
[end]
[include "item_options.html"]
[end]

View File

@ -20,6 +20,3 @@
[include "item_options.html"]

View File

@ -1,7 +1,16 @@
# these tables are used to change url characters
# one character from 'original' table at a specific position
# will be translated to one character from 'changeto' at the same position
# one character from 'url_original' table at a specific position
# will be translated to one character from 'url_changeto' at the same position
url_original = "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ"
url_changeto = "acelnoszzacelnoszz"
# these tables are used to change from small to capital letters
# ASCII characters (a-z, A-Z) are tested beforehand
# so these tables are not used for such characters
smallleters = "ąćęłńóśźż"
capitalics = "ĄĆĘŁŃÓŚŹŻ"
original = "ąćęłńóśźżĄĆĘŁŃÓŚŹŻ"
changeto = "acelnoszzacelnoszz"

474
static/basic/winix.css Executable file
View File

@ -0,0 +1,474 @@
/* ---------------------- clearing -------------------------- */
html, body {
color: black;
background: white;
}
html, body, div, span,
applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
dd, dl, dt, li, ol, ul,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
border: 0;
font-weight: inherit;
font-style: inherit;
font-size: 100%;
line-height: 1.4em;
font-family: inherit;
text-align: left;
vertical-align: baseline;
}
a img, :link img, :visited img {
border: 0;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
ol, ul {
list-style: none;
}
q:before, q:after,
blockquote:before, blockquote:after {
content: "";
}
p.withnext {
margin: 1em 0 0 0;
width: 520px;
}
p.iteminfo {
font-size: 0.7em;
color: #AAAAAA;
margin: 0.4em 0 1.8em 0;
}
p.itemtabinfo {
font-size: 0.7em;
color: #AAAAAA;
margin: 0 0 1em 0;
padding: 0.5em 0 0 0;
}
p.itemtabinfo2 {
font-size: 0.7em;
color: #AAAAAA;
margin: 0 0 1em 0;
padding: 1.5em 0 0 0;
}
.error {
color: red;
font-weight: bold;
}
#additem legend {
display: none;
}
#additem .edit {
margin: 0.3em 0 0.3em 0;
padding: 0.2em;
border: 1px solid #dedede;
display: block;
width: 530px;
}
#additem .editshort {
margin: 0.3em 0 0.3em 0;
padding: 0.2em;
border: 1px solid #dedede;
display: block;
width: 250px;
}
#additem .check {
vertical-align: middle;
}
#additem label {
vertical-align: top;
margin: 0.3em 0 0.3em 0;
padding: 0.2em;
display: block;
}
#additem select {
border: 1px solid #dedede;
width: 100px;
margin: 0.3em 0 0.3em 0;
}
#additem select.contenttype {
width: 150px;
}
#additem select.template {
width: 200px;
}
#additem .privileges {
margin: 0.5em 0 0.5em 0;
border: 1px solid #dedede;
display: block;
width: 100px;
}
#additem .multitext {
margin: 0.5em 0 0.5em 0;
border: 1px solid #dedede;
display: block;
width: 530px;
}
#additem .multitextfull {
margin: 0.5em 0 0.5em 0;
border: 1px solid #dedede;
display: block;
width: 630px;
}
#additem .submit {
margin: 1.5em 0 0.5em 0;
display: block;
width: 10em;
padding: 0.2em;
}
div.itemoptions {
clear: both;
border-top: 1px solid #D1D1E1;
padding: 1em;
margin: 5em 0 1em 0;
}
div.itemoptions h2 {
margin-top: 0;
font-size: 1.1em;
}
ul.itemmenu {
overflow: hidden;
margin: 1em 0 2em 0;
display: block;
}
/* ie6 has some problems */
* html ul.itemmenu {
overflow: visible;
height: 1em;
}
ul.itemmenu li {
display: block;
margin-right: 2em;
font-size: 0.8em;
line-height: 1.8em;
}
div.threadbox {
padding: 0.2em 1em 1em 1em;
}
div.threadboxcolor {
background: #F4F4F4;
border-radius: 8px;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
}
div.threadbox a.threadedit {
margin: 0.5em 0 0 0;
float: right;
font-size: 0.8em;
}
table.forum {
border: 1px solid #D1D1E1;
}
table.forum th {
border: 1px solid #D1D1E1;
}
table.forum td {
border: 1px solid #D1D1E1;
}
table.forum a {
display: block;
padding: 0 4px 0 4px;
}
.smallfont {
font-size: 0.7em;
}
table.tickettab {
border: 1px solid #D1D1E1;
}
table.tickettab th {
font-weight: bold;
}
table.tickettab th, table.tickettab td {
text-align: center;
border: 0;
font-size: 0.7em;
border: 1px solid #D1D1E1;
vertical-align: middle;
}
table.tickettab td.tickettabtitle {
font-size: 1em;
text-align: left;
padding: 0 4px 0 4px;
}
table.tickettab a {
display: block;
padding: 0 4px 0 4px;
}
table.ticket {
margin: 1em 0 1em 0;
}
table.ticket th {
text-align: left;
font-weight: normal;
padding: 0 1em 0 0;
}
table.ticket th, table.ticket td {
border: 0;
vertical-align: middle;
}
table.ticket input {
margin: 0.3em 0 0.3em 0;
padding: 0.2em;
border: 1px solid #dedede;
display: block;
width: 100px;
}
div.ticketinfo {
background: #FFFED5;
padding: 2em;
border: 1px dotted #AFAFAF;
}
div.ticketinfo table th {
text-align: left;
border: 0;
padding: 0 1em 0 0;
}
div.ticketinfo table td {
border: 0;
}
div.ticketinfo p.edit {
font-size: 0.8em;
text-align: right;
float: right;
}
ul.ls_browse li {
display: block;
float: left;
margin: 10px;
list-style-type: none;
}
strong {
font-weight: bold;
}
img.catimage {
max-width: 600px;
}
pre.nowinixbreak {
display: inline;
white-space: normal;
}
/*
from bbcode
*/
span.bbitalic {
font-style: italic;
}
span.bbunderline {
text-decoration: underline;
}
span.bbstrike {
text-decoration: line-through;
}
div.bbquote {
display: block;
padding: 0.5em;
margin: 0.5em 0 1em 0;
border: 1px solid #C3C3C3;
background: #F0F0F0;
}
div.bbquote span.bbquotewho {
font-size: 0.8em;
color: #BABABA;
}
code.bbcode {
display: block;
background-color: #fafafa;
padding: 1em;
font-size: 0.8em;
}
ul.bblist {
margin-left: 2em;
}
ul.bblist li {
list-style-type: disc;
}
span.bbcolyellow {
color: yellow;
}
span.bbcolred {
color: red;
}
span.bbcolgreen {
color: green;
}
span.bbcolblue {
color: blue;
}
span.bbcolbrown {
color: brown;
}
span.bbcolblack {
color: black;
}
ul.galleryimages li {
display: block;
float: left;
margin: 0 0 6px 10px;
}
ul.galleryimages a, ul.galleryimages a:hover, ul.galleryimages a:focus, ul.galleryimages a:active {
background: none;
}
ul.galleryimages img {
background: none;
}
table.mountpoints {
}
table.mountpoints th {
font-weight: bold;
white-space: normal;
text-align: center;
}
table.slog th, table.slog td {
border: 0;
}
td.slogerror {
background: red;
color: white;
}
ul#sortable li{
list-style-type: none;
display: block;
padding: 0.2em 1em 0.2em 1em;
border: 1px solid #D3D3D3;
background: #EDEDED;
margin: 0.3em 0 0.3em 0;
}
ul#sortable input{
width: 30px;
margin: 0 10px 0 0;
}
ul#sortable img {
height: 50px;
}
div#fileupload {
font-size: 0.8em;
}

View File

@ -2,7 +2,7 @@
* This file is a part of Winix
* and is not publicly distributed
*
* Copyright (c) 2008-2010, Tomasz Sowa
* Copyright (c) 2008-2011, Tomasz Sowa
* All rights reserved.
*
*/
@ -36,12 +36,7 @@ void fil_capitalize(Info & i)
const std::wstring & str = i.in.Str();
for(size_t a=0 ; a<str.size() ; ++a)
{
if( str[a]>='a' && str[a]<='z' )
i.out << R(wchar_t(str[a] - 'a' + 'A'));
else
i.out << R(str[a]);
}
i.out << R(locale.ToCapital(str[a]));
}
@ -50,12 +45,7 @@ void fil_tosmall(Info & i)
const std::wstring & str = i.in.Str();
for(size_t a=0 ; a<str.size() ; ++a)
{
if( str[a]>='A' && str[a]<='Z' )
i.out << R(wchar_t(str[a] - 'A' + 'a'));
else
i.out << R(str[a]);
}
i.out << R(locale.ToSmall(str[a]));
}
@ -72,10 +62,7 @@ void fil_firstup(Info & i)
if( str[a]!=' ' && str[a]!='\t' && str[a]!=13 && str[a]!=10 && str[a]!=160 )
was_dot = false;
if( str[a]>='a' && str[a]<='z' )
i.out << R(wchar_t(str[a] - 'a' + 'A'));
else
i.out << R(str[a]);
i.out << R(locale.ToCapital(str[a]));
}
else
{

View File

@ -6,7 +6,8 @@
* All rights reserved.
*
*/
#include <algorithm>
#include "locale.h"
#include "core/log.h"
#include "utf8.h"
@ -102,8 +103,9 @@ void Locale::ReadSubstTable(const char * dir, const char * dir_def)
{
bool read = false;
subst_original.clear();
subst_changeto.clear();
subst_url.clear();
subst_smalllet.clear();
subst_capitallet.clear();
if( dir_def && ReadSubstTable(dir_def) )
read = true;
@ -130,8 +132,10 @@ bool read = false;
if( loc_parser.Parse(file_name) == ConfParser::ok )
{
read = true;
subst_original = loc_parser.table_single[L"original"];
subst_changeto = loc_parser.table_single[L"changeto"];
CreateSubstVector(subst_url, loc_parser.table_single[L"url_original"], loc_parser.table_single[L"url_changeto"]);
CreateSubstVector(subst_smalllet, loc_parser.table_single[L"smallleters"], loc_parser.table_single[L"capitalics"]);
CreateSubstVector(subst_capitallet, loc_parser.table_single[L"capitalics"], loc_parser.table_single[L"smallleters"]);
log << log3 << "Locale: read characters substitution tables from: " << file_name << logend;
}
@ -139,6 +143,28 @@ return read;
}
void Locale::CreateSubstVector(std::vector<SubstItem> & vect, const std::wstring & tab1, const std::wstring & tab2)
{
size_t i, min_size = (tab1.size() < tab2.size()) ? tab1.size() : tab2.size();
SubstItem s;
vect.clear();
if( min_size == 0 )
return;
vect.reserve(min_size);
for(i=0 ; i<min_size ; ++i)
{
s.from = tab1[i];
s.to = tab2[i];
vect.push_back(s);
}
std::sort(vect.begin(), vect.end());
}
void Locale::Read(const char * dir, const char * dir_def)
{
@ -149,9 +175,6 @@ void Locale::Read(const char * dir, const char * dir_def)
}
ReadSubstTable(dir, dir_def);
if( subst_original.size() != subst_changeto.size() )
log << log1 << "Locale: substitution tables have different sizes" << logend;
}
@ -431,20 +454,94 @@ void Locale::UTF8(bool utf)
}
wchar_t Locale::Subst(wchar_t c)
/*
binary search in vect
vect should be sorted by 'from'
if the 'val' is found in vect[].from then vect[].to is reterned
else 'val' is returned
*/
wchar_t Locale::SubstFind(const std::vector<SubstItem> & vect, wchar_t val)
{
size_t i = subst_original.find(c);
if( vect.empty() )
return val;
if( i == std::wstring::npos || i >= subst_changeto.size() )
return c;
size_t o1 = 0;
size_t o2 = vect.size() - 1;
return subst_changeto[i];
if( val < vect[o1].from )
return val;
if( val == vect[o1].from )
return vect[o1].to;
if( val > vect[o2].from )
return val;
if( val == vect[o2].from )
return vect[o2].to;
while( o1 + 1 < o2 )
{
size_t o = (o1 + o2) / 2;
if( val == vect[o].from )
return vect[o].to;
if( val < vect[o].from )
o2 = o;
else
o1 = o;
}
return val;
}
void Locale::Subst(std::wstring & str)
wchar_t Locale::UrlSubst(wchar_t c)
{
return SubstFind(subst_url, c);
}
void Locale::UrlSubst(std::wstring & str)
{
for(size_t i=0 ; i<str.size() ; ++i)
str[i] = Subst(str[i]);
str[i] = UrlSubst(str[i]);
}
wchar_t Locale::ToSmall(wchar_t c)
{
if( c>='A' && c<='Z' )
return c - 'A' + 'a';
return SubstFind(subst_capitallet, c);
}
void Locale::ToSmall(std::wstring & str)
{
for(size_t i=0 ; i<str.size() ; ++i)
str[i] = ToSmall(str[i]);
}
wchar_t Locale::ToCapital(wchar_t c)
{
if( c>='a' && c<='z' )
return c - 'a' + 'A';
return SubstFind(subst_smalllet, c);
}
void Locale::ToCapital(std::wstring & str)
{
for(size_t i=0 ; i<str.size() ; ++i)
str[i] = ToCapital(str[i]);
}

View File

@ -89,19 +89,32 @@ public:
// default: false
void UTF8(bool utf);
// substitution characters
// !! w przyszlosci bedzie zmiana nazw tych metod i bedzie ich wiecej
// !! bedzie zmiana do url, do wielkosci liter (male/duze) i moze inne
wchar_t Subst(wchar_t c);
void Subst(std::wstring & str);
// url substitution characters
wchar_t UrlSubst(wchar_t c);
void UrlSubst(std::wstring & str);
// changing to small/capital letters
wchar_t ToSmall(wchar_t c);
void ToSmall(std::wstring & str);
wchar_t ToCapital(wchar_t c);
void ToCapital(std::wstring & str);
private:
// struct to used for substitution
struct SubstItem
{
wchar_t from, to;
bool operator<(const SubstItem & arg) const { return from < arg.from; }
};
void AddLocale(size_t lang);
void ReadFile(const char * dir, const char * dir_def, size_t lang, const char * file);
bool ReadFile(const char * dir, size_t lang, const char * file);
void ReadSubstTable(const char * dir, const char * dir_def);
bool ReadSubstTable(const char * dir);
void CreateSubstVector(std::vector<SubstItem> & vect, const std::wstring & tab1, const std::wstring & tab2);
wchar_t SubstFind(const std::vector<SubstItem> & vect, wchar_t val);
// locale files
// we have at least one item "en"
@ -115,9 +128,10 @@ private:
// this table has the same size as locale_files (at least one item)
std::vector<ConfParser::Table> loc_tab_multi;
// these tables are used to change url characters
std::wstring subst_original;
std::wstring subst_changeto;
// vectors of characters substitution (sort by 'from')
std::vector<SubstItem> subst_url;
std::vector<SubstItem> subst_smalllet; // changing from small to capital
std::vector<SubstItem> subst_capitallet; // changing from capital to small
ConfParser loc_parser;