Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: midgardproject/midgardproject.github.com
base: 0fce9db145
...
head fork: midgardproject/midgardproject.github.com
compare: 3f4f37f8c6
Checking mergeability… Don't worry, you can still create the pull request.
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
8 discussion/index.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="http://lists.midgard-project.org/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=http://lists.midgard-project.org/" />
+ </head>
+ </html>
View
29 midcom/_posts/2012-05-16-configuration.md
@@ -0,0 +1,29 @@
+---
+name: config
+title: "Component configuration"
+---
+MidCOM components use a configuration system to make their behaviour customizable. The configuration system is based on defining _configuration keys_ with values that the site builder can change.
+
+The configuration can be modified on three different levels:
+
+* Global configuration shipping with the component: stored in files
+* Sitegroup -specific configuration: stored in snippets
+* Folder -specific configuration: stored in folder parameters
+
+## Configuration file format
+
+The file format used for the configuration file and the sitegroup configuration snippets is in the [PHP associative array][1] format but without the starting `<?php` tags:
+
+ 'results_per_page' => 10,
+
+## Component's default configuration
+
+The default values for component's configuration reside in the component's `config/config.inc` file.
+
+## Sitegroup-specific configuration
+
+Custom configuration snippets for MidCOM components can be placed in `config` snippet, which is placed in snippet directory `/sitegroup-config/<component name>/`. This can be done eg. in Asgard on the _Snippets_ tab.
+
+In most components, it is possible to define the default Datamanager2 schema of the sitegroup and - depending on the component - define an array of schemas to choose from in component configuration.
+
+[1]: http://www.php.net/manual/en/language.types.array.php
View
135 midcom/_posts/2012-05-16-multilang.md
@@ -0,0 +1,135 @@
+---
+name: multilang
+title: Building multilingual sites
+---
+With [Midgard1](/midgard1/) and above the recommended way is to use [MultiLang](multilanguage) feature even if the site structure isn't identical among different languages.
+
+If content hasn't been translated will master language (language 0) be used.
+
+Using multilang
+---------------
+
+`mgd_set_lang(int language)`
+
+Languages are called with their ID. E.g. `mgd_set_lang(38)` would set the language to English and `mgd_set_lang(183)` to Inuktitut.
+
+For the master language key _0_ (zero) is used. Master language isn't fixed to any specific language, so it can be the main language, which other languages will be translated from.
+
+### Get the currently used languages
+
+It is possible to use two languages simultaneously
+
+1. Content language
+2. Interface language
+
+To get the content language use
+
+ <?php
+ // Get ID (integer) of the content language
+ $content_language = $_MIDCOM->i18n->get_content_language();
+ ?>
+
+And for the currently used interface language (e.g. toolbar) use
+
+ <?php
+ // Get ID (integer) of the current interface language
+ $interface_language = $_MIDCOM->i18n->get_current_language();
+ ?>
+
+### Using parameters as storage location
+
+To use multilanguage parameters with _midcom.helper.datamanager2_ it is possible to set the parameter storage location in the following way:
+
+ 'price' => array
+ (
+ 'title' => 'price',
+ 'type' => 'text',
+ 'storage' => array
+ (
+ 'location' => 'parameter',
+ 'multilang' => true,
+ ),
+ 'widget' => 'text',
+ ),
+
+This will save the parameters
+
+* _midcom.helper.datamanager2_, _price_, _$value_ for the master language
+ content
+* _midcom.helper.datamanager2_, _price_fi_, _$value_ for Finnish language
+ content
+
+
+Untranslated content
+--------------------
+
+Component `fi.protie.navigation` will natively add class _untranslated_ for content which is lacking the translation.
+
+Otherwise untranslated content should be checked with
+
+ <?php
+ if ($object->lang !== $_MIDCOM->i18n->get_midgard_language())
+ ?>
+
+### Hiding untranslated content
+
+To hide untranslated content (otherwise master language will be displayed, resulting in displaying mixed language) set the MidCOM configuration parameter
+
+ $GLOBALS['midcom_config_local']['i18n_multilang_strict'] = true;
+
+before initializing MidCOM in code-init.
+
+
+Language versions for the requested object
+------------------------------------------
+
+To get a list of the language versions for a requested object do the following
+
+### MidCOM component level
+
+ <?php
+ // Get the metadata for the requested object
+ $object_metadata = midcom_helper_metadata::retrieve($object);
+
+ if ( $object_metadata
+ && $object_metadata->id)
+ {
+ $languages = $object_metadata->get_languages();
+ }
+ // returns an array with the languages
+ ?>
+
+### On layout level
+
+ <?php
+ // Get the metadata binded to the object currently viewed
+ // if the component binds the metadata
+ $object_metadata = $_MIDCOM->metadata->get_view_metadata();
+
+ if ( $object_metadata
+ && $object_metadata->id)
+ {
+ $languages = $object_metadata->get_languages();
+ }
+ ?>
+
+### Multilang and hosts
+
+If host record has language other than _0_, mgd_set_lang is automatically initialized to set the correct language.
+
+To fetch a list of all the languages hosts use get an array containing the host objects with
+
+ <?php
+ $hosts = $_MIDCOM->i18n->get_language_hosts();
+ // Returns an array of languages, indexed with the language id as
+ // the array key for each language
+ ?>
+
+MySQL and object level
+----------------------
+
+Several objects have two different types of properties: shared and language-dependant. For example table _article_ shares e.g. name and the language content is located in _article\_i_, which contains _title_, _abstract_, _content_ and such.
+
+Languages are located in table _midgard\_language_.
+
+[`midgard_query_builder`](/midgard1/#qb) will automatically set language constraint when applicable.
View
109 midcom/_posts/2012-05-16-solr.md
@@ -0,0 +1,109 @@
+---
+name: solr
+title: "Site search using Solr"
+---
+Solr is an open source enterprise search server based on the Lucene Java search library, with XML/HTTP and JSON APIs, hit highlighting, faceted search, caching, replication, and a web administration interface. It runs in a Java servlet container such as Tomcat.
+
+That means that to use Solr you will need to run in some Java servlet container.
+
+## Using solr-tomcat5.5
+
+On Ubuntu et co we have this package available and dependency of the midgard metapackage, so after installing just do the following:
+
+1. Make sure the Catalina process uses [UTF-8 for URI parsing][utf8]
+2. Download the [MidCOM Solr Schema][schema] and copy over `/etc/solr/conf/schema.xml`
+3. Configure your website to use the indexer
+ Set the following values in `code-init-before-midcom`:
+
+ $GLOBALS['midcom_config_local']['indexer_reindex_allowed_ips'] = array ( '127.0.0.1', 'server.main.ip' );
+ $GLOBALS['midcom_config_local']['indexer_backend'] = 'solr';
+ $GLOBALS['midcom_config_local']['indexer_xmltcp_host'] = 'localhost';
+ $GLOBALS['midcom_config_local']['indexer_xmltcp_port'] = '8180';
+
+
+If you get `java.lang.NoClassDefFoundError` in Tomcat logs you may need to [disable Tomcat security][secerror]
+
+[utf8]: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding#Q2
+[schema]: http://trac.midgard-project.org/browser/trunk/external-tools/indexer-backends/solr/schema.xml
+[secerror]: http://yousefourabi.com/blog/2007/12/running-solr-on-debian-with-tomcat/
+
+## Using Jetty
+
+**Warning:** This section is very old, we suggest using Tomcat
+
+### Dependencies
+On Debian you need the following packages:
+
+ apt-get install libmx4j-java libregexp-java libsablevm-classlib1-java libservlet2.4-java libtomcat5.5-java libxerces2-java sun-java5-jdk
+
+### Installing Jetty
+
+Solr comes with Jetty in the example directory.
+
+### Installing Solr
+
+**Note:** You must use version 1.1 of Solr
+
+1. Download Solr from the Solr website
+<http://www.apache.org/dyn/closer.cgi/lucene/solr/>
+
+2. Unpack solr and copy the jetty example install to the jetty home.
+
+ unzip apache-solr-1.1\*.zip
+ cp -R apache-solr-1.1\*/example /usr/share/jetty
+
+3. Download the setupfiles for Solr. (Currently just for Debian)
+
+ svn co https://svn.midgard-project.org/midgard/trunk/external-tools/indexer-backends/solr
+ cd solr
+ bash ./install-solr.sh
+
+This will install setupfiles in the correct places and set the correct permissions.
+
+4. Start solr
+
+ /etc/init.d/jetty start
+
+Now solr is running and listening to requests on port 8983.
+
+5. Create a topic with the Search component.
+
+6. In the menu, choose website -> website configuration.
+
+7. Set the following values:
+
+ * Indexer: Solr
+ * Hostname of indexer xmltcp service: localhost (or the host solr is running on)
+ * Port of indexer xmltcp service: 8983
+
+8. Reindex your site.
+Visit `/midcom-exec-midcom/reindex.php`. This will take some time.
+
+9. You should now be able to run searches on your site.
+
+### Security
+
+In the `addListener` definition in `jetty.xml`, add the following:
+
+ <Set name="Host">localhost</Set>
+
+So Jetty doesn't listen to requests from the outside. If you want to still access the admin interface, use firewall scripts to hide the port from most users.
+
+See <http://wiki.apache.org/solr/SolrSecurity> for more information.
+
+### Troubleshooting
+
+#### "Authorization required"
+
+When you're running `midcom-exec-midcom/reindex.php`, and you get "Authorization required" errors, you should modify the `indexer_reindex_allowed_ips`. Either set it in `/etc/midgard/midcom.conf` or in the host settings.
+
+For the `midcom.conf` file, you need to add:
+
+ $GLOBALS['midcom_config_site']['indexer_reindex_allowed_ips'] = array('127.0.0.1','192.168.126.128','127.0.1.1');
+
+#### "Indexer failed"
+
+If you get an "indexer failed" error when reindexing the site, ensure that SOLR's data directory exists and is writable:
+
+ mkdir /usr/share/jetty/solr/data
+ chown jetty /usr/share/jetty/solr/data
View
119 midcom/_posts/2012-05-16-squid.md
@@ -0,0 +1,119 @@
+---
+name: proxy
+title: "Setting up Squid reverse proxy"
+---
+On high-volume sites significant performance improvements can be attained by setting up a reverse proxy in front of the actual Midgard, [Squid](http://www.squid-cache.org/) is a popular choice.
+
+### Caveats
+
+Obviously since we're aggressively caching stuff it will normally take at least the lifetime of an object before it's refreshed from main server and thus your changes to the content will appear with some delay. Also since we're not sending MidCOMs usual 'must-revalidate' headers, some clients (yes, that would be IE) may cache the pages locally for much longer...
+
+## Setup options
+
+This document covers a single machine proxy and Midgard setup, Squid makes it possible to make clusters of proxies for even higher performance, see Squid documentation on how to do that.
+
+For our case we have basically two options:
+
+ 1. One (public) IP for Squid and another (public or internal) for Midgard
+ - This has the advantage of simplifying installation and management as long as the Midgard IP
+ is reachable by the content maintainers.
+ - It also simplifies Midgard/MidCOM headers debugging
+ 2. One (public) IP for Squid and 127.0.0.1 (localhost) for Midgard
+ - In this case access to the content management becomes troublesome but for staging-live setups this works well.
+
+The third option of having Midgard and Squid in same IP but different ports has a problem with the fact that a lot of places use `MIDCOM_NAV_FULLURL` in stead of `MIDCOM_NAV_RELATIVEURL` (and in some cases they don't really have much of a choice), where the nonstandard port is then added to the constructed URLs everywhere, bypassing the cache from first hit onwards...
+
+## Midgard setup changes
+
+Set up apache to bind specifically to the chosen IP (here we use 127.0.0.1), basically comment out all `Listen` and `NameVirtualHost` directives you can find and then add new ones to `/etc/midgard/apache/httpd.conf`
+
+ Listen 127.0.0.1:80
+ NameVirtualHost 127.0.0.1:80
+
+Then in each file in `/etc/midgard/apache/vhosts` change the `<VirtualHost *:80>` to `<VirtualHost 127.0.0.1:80>`
+
+## Squid setup
+
+Install normally, make sure Squid can resolve the servers IPs to names (edit `/etc/hosts` if needed). Then set up as reverse proxy by changing the following settings in `/etc/squid/squid.conf`.
+
+### Acceleration options with Squid 2.5
+
+ http_port "public-ip-address":80
+ httpd_accel_host "127.0.0.1"
+ httpd_accel_port 80
+ httpd_accel_uses_host_header on
+
+### Acceleration options with Squid 2.6
+
+ http_port "public-ip-address":80 vhost vport
+ cache_peer "public-ip-address" parent 80 0 originserver default
+
+### Access control options
+
+Then add ACLs for allowing your site to be proxied, here's one example but I recommend reading the Squid documentation on ACLs
+
+ acl valid_dst dstdomain .example.com
+ http_access allow valid_dst (Just before deny all!)
+
+## MidCOM setup
+
+in `code-init` of your host(s) add the following settings:
+
+ $GLOBALS['midcom_config_local']['cache_module_content_headers_strategy'] = 'public';
+ $GLOBALS['midcom_config_local']['cache_module_content_default_lifetime'] = 60;
+
+
+Adjust the default lifetime as you see fit, this is in seconds (in case the document has no expiry set via metadata then the expiry is set to current time plus the default lifetime, lower values significantly reduce the advantages of proxy)
+
+You can also use 'private' in stead of 'public' in case you need that kind of cache-control, but be aware that currently whenever a user is logged in midcom enters no-cache mode due to uimessages service unconditionally using sessions.
+
+
+## Testing & Troubleshooting
+
+Read [Six Things First-Time Squid Administrators Should Know](http://www.onlamp.com/pub/a/onlamp/2004/02/12/squid.html) from ONLamp.com.
+
+Remember to restart Squid and Apache after each configuration change, only test one change at a time, keep log of what you changed, where and why.
+
+First test a few times with
+
+ lynx --dump --head http://www.yoursite.com/
+
+look for headers indicating cache miss/hit, if you get only misses increase Squid logging and see in the store and squid logs exactly what happens.
+
+If a page is released immediately from the cache there are a few options:
+
+ 1. `Cache-Control` headers are incorrect
+ - Use lynx or telnet to examine the headers you get from Midgard
+ - If you get `Cache-Control: no-store, no-cache, must-revalidate` header then MidCOM is in no-cache mode for some reason.
+ 2. `Content-Lenght` header is incorrect
+ - For some reason in some cases there is extra whitespace sent in MidCOM output, for this reason we try to avoid sending Content-Lenght header when headers_strategy indicates caching.
+ - See Squid debug level log, it should complain about server sending more data than announced.
+ 3. `Expires` is now or in the past (remember that the header is in GMT, so what might seem like past at first sight perhaps is not...)
+ - Make sure the document does not have expiry set to past (though normally it shouldn't be then available on the site at all).
+ - Make sure the default_lifetime is sensible.
+
+## Performance testing
+
+Get [Siege](ftp://ftp.joedog.org/pub/siege) and create `urls.txt` with one url per line, this should contain enough urls from your site (dump a sitemap or something), then in one window:
+
+ tail -F /var/log/squid/access.log
+
+And in another
+
+ siege -c 30 -i -t 5m -f urls.txt
+
+And see what happens. Tune Squid as needed, below are some settings I have used:
+
+ cache_replacement_policy heap LFUDA
+ memory_replacement_policy heap GDSF
+ cache_dir ufs /usr/local/squid/cache 20000 16 256
+ cache_mem 500MB
+ maximum_object_size 12000 KB
+
+## Forcing cache refresh / precaching
+
+You can use wget to precache your site and/or to force a cache refresh for the whole site with the following command:
+
+ wget -t 3 -T 3 --no-cache -q -m www.yoursite.com
+
+For forcing refresh of single page in the cache, go to the page and 'shift-reload' (or whatever works on your browser for forcing it to reload the full page from server).
View
48 midcom/_posts/2012-05-16-styles.md
@@ -0,0 +1,48 @@
+---
+name: styles
+title: "Modifying component output"
+---
+MidCOM components use the style engine for all their output, meaning that site builders can easily __modify all component output__ by simply overriding templating.
+
+## Default style elements
+
+MidCOM components ship a set of templates that are stored in the `style` subdirectory of the component.
+
+The template files are regular PHP files that are executed in their own context.
+
+__Example:__ [Templates of net.nehmer.blog in SVN][1]
+
+## Overriding the templates
+
+You can override any output template of a component by logging into Asgard and creating a new substyle under your site's style. It is a good idea to name the substyles according to their use, like _Photo gallery_ or _Blog_.
+
+Then copy the style template that you want to override from the component and create a `midgard_element` with the same name (but trailing `.php` removed) under your new substyle and paste the contents there. Make some change and save it.
+
+Then log into your site and click `Edit Topic`. In the editor you'll have a pulldown for selecting a _Style_. Select your new substyle.
+
+Then simply go to the site and see how the changes have taken effect.
+
+If your site uses output caching, you might have to access the `/midcom-cache-invalidate` URL first.
+
+## Dynamic Loading
+
+__Dynamic Load__ is a MidCOM method which loads content dynamically from components.
+
+Example: loading 5 latest news items from a _net.nehmer.blog_ folder:
+
+ <?php
+ $_MIDCOM->dynamic_load("/news/latest/5");
+ ?>
+
+### Substyles
+
+Dynamic load can also be used to utilize a substyle for component's output:
+
+ <?php
+ // Using a substyle called 'frontpage'
+ $_MIDCOM->dynamic_load("/midcom-substyle-frontpage/news/latest/5");
+ ?>
+
+The used substyle is loaded as a child style under the style which is used for the loaded folder.
+
+[1]: http://trac.midgard-project.org/browser/branches/ragnaroek/midcom/net.nehmer.blog/style
View
4 midcom/_posts/2012-05-17-pear.md
@@ -1,6 +1,8 @@
---
title: "Installing MidCOM with PEAR"
-name: pear
+name: source
+tags:
+ - download
---
MidCOM releases are shipped as PEAR packages for better version management and control. The packages utilize a MidCOM-specific channel in [ragnaroek.pear.midgard-project.org](http://ragnaroek.pear.midgard-project.org/).
View
8 midgard/8.09/index.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/midgard1/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/midgard1/" />
+ </head>
+ </html>
View
8 midgard/index.html
@@ -0,0 +1,8 @@
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <link rel="canonical" href="/midgard1/"/>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <meta http-equiv="refresh" content="0;url=/midgard1/" />
+ </head>
+ </html>

No commit comments for this range

Something went wrong with that request. Please try again.