This commit is contained in:
marijus 2014-03-02 10:27:08 +01:00
commit 2313736e92
12 changed files with 473 additions and 300 deletions

View File

@ -1852,7 +1852,11 @@ function construct_page(&$a) {
require_once('include/js_strings.php');
if(x($a->page,'template_style'))
head_add_css($a->page['template_style'] . '.css');
else
head_add_css(((x($a->page,'template')) ? $a->page['template'] : 'default' ) . '.css');
head_add_css('mod_' . $a->module . '.css');
head_add_css(current_theme_url($installing));

View File

@ -19,9 +19,9 @@ Currently there are two layout templates, unless your site provides additional l
The full template defines the same as the default template with the exception that there is no "aside" region.
To choose a layout template, use the 'layout' tag.
To choose a layout template, use the 'template' tag.
[layout]full[/layout]
[template]full[/template]
The default template will be used if no other template is specified. The template can use any names it desires for content regions. You will be using 'region' tags to decide what content to place in the respective regions.
@ -100,11 +100,11 @@ The 'comment' tag is used to delimit comments. These comments will not appear on
**Complex Example**
Please note that pasting this example into a layout page is not likely to do anything useful as the chosen names (layout, theme, regions, etc.) may not correspond to any existing webpage components.
Please note that pasting this example into a layout page is not likely to do anything useful as the chosen names (template, theme, regions, etc.) may not correspond to any existing webpage components.
[comment]use an existing page template which provides a banner region plus 3 columns beneath it[/comment]
[layout]3-column-with-header[/layout]
[template]3-column-with-header[/template]
[comment]Use the "darknight" theme[/comment]

91
doc/Creating-Templates.md Normal file
View File

@ -0,0 +1,91 @@
Creating Page Templates
=======================
A page template for use with Comanche requires two files - a PHP template and a CSS file. Page templates will need to be installed by the system administrator of your site.
First choose a name. Here we'll create a template and call it "demo".
You will need to create the files "view/php/demo.php" and "view/css/demo.css" to hold the PHP template and CSS respectively.
To get a better idea of this process, let's look at an existing template - the "default" template. This is used by default throughout the application.
view/php/default.php
====================
<!DOCTYPE html >
<html>
<head>
<title><?php if(x($page,'title')) echo $page['title'] ?></title>
<script>var baseurl="<?php echo $a->get_baseurl() ?>";</script>
<?php if(x($page,'htmlhead')) echo $page['htmlhead'] ?>
</head>
<body>
<?php if(x($page,'nav')) echo $page['nav']; ?>
<aside id="region_1"><?php if(x($page,'aside')) echo $page['aside']; ?></aside>
<section id="region_2"><?php if(x($page,'content')) echo $page['content']; ?>
<div id="page-footer"></div>
<div id="pause"></div>
</section>
<aside id="region_3"><?php if(x($page,'right_aside')) echo $page['right_aside']; ?></aside>
<footer><?php if(x($page,'footer')) echo $page['footer']; ?></footer>
</body>
</html>
Here's is the corresponding CSS file
view/php/default.css
====================
aside#region_1 {
display: block;
width: 210px;
position: absolute;
top: 65px;
left: 0;
margin-left: 10px;
}
aside input[type='text'] {
width: 174px;
}
section {
position: absolute;
top: 65px;
left: 250px;
display: block;
right: 15px;
padding-bottom: 350px;
}
Some things you may notice when looking at these definitions:
* We have not specified any CSS for the "nav", "right_aside", or "footer" regions. In this template "nav" and "footer" will be the full page width and we will let the size and placement of these elements be controlled by the theme. "right_aside" is not currently used.
* There are elements on the page such as "page-footer" and "pause" for which there is no apparent content. This content will come from Javascript elements.
* Our default template uses absolute positioning. Modern web design often uses "float" div containers so that scrollbars aren't typically needed when viewing on small-screen devices.
To design a new template, it is best to start with an existing template, and modify it as desired. That is what we will do here.
The way that Comanche provides content inside a specific region is by using a region tag.
[region=aside][widget=profile][/widget][/region]
This example will place a "profile" widget in the "aside" region. But what it actually does is place the HTML for the widget into a code variable **$page['aside']**. Our default page template defines a region on the page (the CSS positions this as an absolute sidebar) and then inserts the contents of $page['aside'] (if it exists).
So if you wanted to create a template with a region named "foo", you would provide a place for it on the page, then include the contents of $page['foo'] wherever you wanted to use it, and then using Comanche, you could specify
[region=foo][widget=profile][/widget][/region]
and this would place a profile widget into the "foo" region you created.
Use the CSS file to position the region on the page where desired and optionally control its size.
[To be continued]

View File

@ -18,10 +18,10 @@ Currently there are two layout templates, unless your site provides additional l
The full template defines the same as the default template with the exception that there is no &quot;aside&quot; region.
[/code]
To choose a layout template, use the 'layout' tag.
To choose a layout template, use the 'template' tag.
[code]
[layout]full[/layout]
[template]full[/template]
[/code]
The default template will be used if no other template is specified. The template can use any names it desires for content regions. You will be using 'region' tags to decide what content to place in the respective regions.
@ -98,7 +98,7 @@ The 'comment' tag is used to delimit comments. These comments will not appear on
[code]
[comment]use an existing page template which provides a banner region plus 3 columns beneath it[/comment]
[layout]3-column-with-header[/layout]
[template]3-column-with-header[/template]
[comment]Use the &quot;darknight&quot; theme[/comment]

View File

@ -36,6 +36,7 @@
[zrl=[baseurl]/help/install]Install[/zrl]
[zrl=[baseurl]/help/comanche]Comanche Page Descriptions[/zrl]
[zrl=[baseurl]/help/Creating-Templates]Creating Comanche Templates[/zrl]
[zrl=[baseurl]/help/plugins]Plugins[/zrl]
[zrl=[baseurl]/help/schema_development]Schemas[/zrl]
[zrl=[baseurl]/help/developers]Developers[/zrl]

View File

@ -57,6 +57,16 @@ function comanche_parser(&$a,$s) {
if($cnt)
$a->page['template'] = trim($matches[1]);
$cnt = preg_match("/\[template=(.*?)\](.*?)\[\/template\]/ism", $s, $matches);
if($cnt) {
$a->page['template'] = trim($matches[2]);
$a->page['template_style'] = trim($matches[2]) . '_' . $matches[1];
}
$cnt = preg_match("/\[template\](.*?)\[\/template\]/ism", $s, $matches);
if($cnt) {
$a->page['template'] = trim($matches[1]);
}
$cnt = preg_match("/\[theme=(.*?)\](.*?)\[\/theme\]/ism", $s, $matches);
if($cnt) {

View File

@ -1 +1 @@
2014-02-28.602
2014-03-02.604

View File

@ -13,3 +13,4 @@
[widget=affinity][/widget]
$content
[/region]

View File

@ -1 +1 @@
[layout]full[/layout]
[template]full[/template]

View File

@ -1 +1 @@
[layout]full[/layout]
[template]full[/template]

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,8 @@ $a->strings["Settings"] = "Configurações";
$a->strings["Check Mail"] = "Checar mensagens";
$a->strings["New Message"] = "Nova mensagem";
$a->strings["Chat Rooms"] = "Salas de bate-papo";
$a->strings["Bookmarked Chatrooms"] = "Salas de bate-papo guardadas";
$a->strings["Suggested Chatrooms"] = "Salas de bate-papo sugeridas";
$a->strings["Visible to everybody"] = "Visível para todos";
$a->strings["show"] = "exibir";
$a->strings["don't show"] = "não exibir";
@ -315,13 +317,15 @@ $a->strings["Delete this item?"] = "Excluir este item?";
$a->strings["Comment"] = "Comentar";
$a->strings["show more"] = "exibir mais";
$a->strings["show fewer"] = "exibir menos";
$a->strings["+ Show More"] = "+ Exibir Mais";
$a->strings["- Show Less"] = "- Exibir Menos";
$a->strings["Password too short"] = "A senha é muito curta";
$a->strings["Passwords do not match"] = "As senhas não correspondem";
$a->strings["everybody"] = "todos";
$a->strings["Secret Passphrase"] = "Frase secreta";
$a->strings["Passphrase hint"] = "Dica da frase secreta";
$a->strings["timeago.prefixAgo"] = "timeago.prefixAgo";
$a->strings["timeago.suffixAgo"] = "timeago.suffixAgo";
$a->strings["timeago.prefixFromNow"] = "timeago.prefixFromNow";
$a->strings["ago"] = "atrás";
$a->strings["from now"] = "de agora";
$a->strings["less than a minute"] = "menos de um minuto";
@ -469,8 +473,8 @@ $a->strings["Nickname has unsupported characters or is already being used on thi
$a->strings["Unable to retrieve created identity"] = "Não foi possível recuperar a identidade criada";
$a->strings["Default Profile"] = "Perfil padrão";
$a->strings["Requested channel is not available."] = "Canal solicitado não está disponível.";
$a->strings[" Sorry, you don't have the permission to view this profile. "] = "Desculpe, você não tem permissão para ver este perfil.";
$a->strings["Requested profile is not available."] = "O perfil solicitado não está disponível.";
$a->strings[" Sorry, you don't have the permission to view this profile. "] = "Desculpe, você não tem permissão para ver este perfil.";
$a->strings["Change profile photo"] = "Mudar a foto do perfil";
$a->strings["Profiles"] = "Perfis";
$a->strings["Manage/edit profiles"] = "Administrar/editar perfis";
@ -744,7 +748,7 @@ $a->strings["Can send me bookmarks"] = "Pode me enviar links guardados";
$a->strings["Can administer my channel resources"] = "Pode administrar os recursos do meu canal";
$a->strings["Extremely advanced. Leave this alone unless you know what you are doing"] = "Extremamente avançado. Não mexa nisso a não ser que saiba o que está fazendo";
$a->strings["Permission denied"] = "Permissão negada";
$a->strings["Unknown"] = "Desconhecidos";
$a->strings["(Unknown)"] = "(Desconhecido)";
$a->strings["Item not found."] = "O item não foi encontrado.";
$a->strings["Collection not found."] = "A coleção não foi encontrada.";
$a->strings["Collection is empty."] = "A coleção está vazia.";
@ -965,9 +969,11 @@ $a->strings["Channel not found."] = "O canal não foi encontrado.";
$a->strings["toggle full screen mode"] = "alternar o mode de tela inteira";
$a->strings["%1\$s tagged %2\$s's %3\$s with %4\$s"] = "%1\$s etiquetou %3\$s de %2\$s com %4\$s";
$a->strings["You must be logged in to see this page."] = "Você precisa estar autenticado para ver esta página.";
$a->strings["Room not found"] = "Sala não encontrada";
$a->strings["Leave Room"] = "Sair da sala";
$a->strings["I am away right now"] = "Eu estou ausente no momento";
$a->strings["I am online"] = "Eu estou online";
$a->strings["Bookmark this room"] = "Guarde esta sala";
$a->strings["New Chatroom"] = "Nova sala de bate-papo";
$a->strings["Chatroom Name"] = "Nome da sala de bate-papo";
$a->strings["%1\$s's Chatrooms"] = "Salas de bate-papo de %1\$s";
@ -996,8 +1002,6 @@ $a->strings["Existing Page Delegates"] = "Atuais delegados da página";
$a->strings["Potential Delegates"] = "Potenciais delegados";
$a->strings["Add"] = "Adicionar";
$a->strings["No entries."] = "Sem entradas.";
$a->strings["Away"] = "Ausente";
$a->strings["Online"] = "Online";
$a->strings["Item not available."] = "O item não está disponível.";
$a->strings["Menu element updated."] = "O elemento de menu foi atualizado.";
$a->strings["Unable to update menu element."] = "Não foi possível atualizar o elemento de menu.";
@ -1217,6 +1221,7 @@ $a->strings["Unhide"] = "Não ocultar";
$a->strings["Hide"] = "Ocultar";
$a->strings["Hide or Unhide this connection"] = "Ocultar ou deixar de ocultar esta conexão";
$a->strings["Delete this connection"] = "Deletar esta conexão";
$a->strings["Unknown"] = "Desconhecidos";
$a->strings["Approve this connection"] = "Aprovar esta conexão";
$a->strings["Accept connection to allow communication"] = "Aceite a conexão para permitir comunicação";
$a->strings["Automatic Permissions Settings"] = "Configurações de permissão automáticas";
@ -1467,6 +1472,11 @@ $a->strings["Forgot your Password?"] = "Esqueceu a sua senha?";
$a->strings["Enter your email address and submit to have your password reset. Then check your email for further instructions."] = "Digite o seu endereço de e-mail e clique em 'Restaurar' para prosseguir com a restauração da sua senha. Após isso, verifique seu e-mail para mais instruções.";
$a->strings["Email Address"] = "Endereço de e-mail";
$a->strings["Reset"] = "Restaurar";
$a->strings["Select a bookmark folder"] = "Escolha uma pasta de links onde guardar";
$a->strings["Save Bookmark"] = "Guardar link";
$a->strings["URL of bookmark"] = "URL do link guardado";
$a->strings["Description"] = "Descrição";
$a->strings["Or enter new bookmark folder name"] = "Ou digite o nome para uma nova pasta de links";
$a->strings["Nothing to import."] = "Nada a importar.";
$a->strings["Unable to download data from old server"] = "Não foi possível descarregar os dados do servidor antigo";
$a->strings["Imported file is empty."] = "O arquivo importado está vazio.";
@ -1498,6 +1508,8 @@ $a->strings["No keywords to match. Please add keywords to your default profile."
$a->strings["is interested in:"] = "se interessa por:";
$a->strings["No matches"] = "Nenhuma correspondência";
$a->strings["invalid target signature"] = "assinatura do destino inválida";
$a->strings["Away"] = "Ausente";
$a->strings["Online"] = "Online";
$a->strings["Unable to lookup recipient."] = "Não foi possível encontrar o destinatário.";
$a->strings["Unable to communicate with requested channel."] = "Não foi possível comunicar com o canal solicitado.";
$a->strings["Cannot verify requested channel."] = "Não foi possível verificar o canal requisitado.";
@ -1674,6 +1686,7 @@ $a->strings["Scheme Default"] = "Padrão do esquema";
$a->strings["silver"] = "prata";
$a->strings["Theme settings"] = "Configurações de tema";
$a->strings["Set scheme"] = "Definir esquema";
$a->strings["Narrow navbar"] = "Barra de navegação estreita";
$a->strings["Navigation bar colour"] = "Cor da barra de navegação";
$a->strings["link colour"] = "cor dos links";
$a->strings["Set font-colour for banner"] = "Definir a cor da fonte para o cartaz";