# Dev/Design/Files/Wikia

From XOWA: the free, open-source, offline wiki application

## Overview

Some wikis are not Wikimedia Foundation wikis, and may not have their images / files arranged in a WMF filesystem layout

XOWA supports using files from a single directory.

## Background

Wikimedia Foundation wikis place their images in a precisely defined filesystem layout.

For example, a file in a WMF tarball may have the following path /wmf_tarball/wikipedia/commons/7/70/A.png

Note that this path embeds the MD5 hash of the title in the path. In this case "70" are the first two characters of the MD5 hash for "A.png" which is "701ccaf6ec1641a9ff778fd0b862e5a2"

Because an MD5 hash is a non-trivial function, non-WMF wikis may find it difficult to arrange their files in the same filesystem layout.

XOWA allows these wikis to use an alternate method, where the files need only be placed inside a single directory.

## Instructions

- Go to home/wiki/Help:Options/Config script
- Enter in the following:

    app.wikis.get('my_wiki').files.wkrs.get('fs.dir') {
      orig_dir      = '~{<>xowa_root_dir<>}wiki/my_wiki/orig/';
      thumb_dir     = '~{<>xowa_root_dir<>}wiki/my_wiki/thumb/';
    }

- Place a file called "A.png" in "~{<>xowa_root_dir<>}wiki/my_wiki/orig/". For example, if XOWA is setup on a Windows machine at C:\xowa\ and your wiki is my_wiki, then your file should be at C:\xowa\wiki\my_wiki\orig\A.png.
- Restart XOWA
- Go to any page in my_wiki
- Enter in [[File:A.png]]
- Preview the page. The file should show
- Enter in [[File:A.png|200px]]
- Preview the page. The thumb should show

## Image Magic and Inkscape

- You must have ImageMagick and Inkscape installed on your machine. They are needed because:
  - MediaWiki has a lot of logic that depends on the image's size. ImageMagick is used to get the size.
  - Thumbs are resized from the original. ImageMagick and Inkscape does the resizing.

## ^orig_regy.sqlite3

- A file called "^orig_regy.sqlite3" will be in the orig directory.
  - This db caches the sizes of the original files (so ImageMagick doesn't need to be continually run).
  - Note that if this file is deleted, it will be automatically regenerated

## Urls

- XOWA takes the following type of urls
  - Absolute urls: C:\xowa\wiki\my_wiki\images\
  - XOWA relative urls: ~{<>xowa_root_dir<>}wiki/my_wiki/images/
    - Note that relative urls can use the "\" instead of the "/". However, it is recommended to use "/" for sharing across different machines (for example, the same USB drive can be used on both a Windows or Linux machine if a "/" path is used)
- File names need to comply with valid MediaWiki titles. For example, certain characters are invalid, such as [].

## Orig directory

- All original files should go into the orig directory
- The orig directory can be nested.
  - For example, /xowa/wiki/my_wiki/orig/ can have a subfile in /xowa/wiki/my_wiki/orig/level_0/level_00/A.png.
  - [[File:A.png]] will pick up this file
  - Note that file names should be unique with a given folder. If there are two files called A.png in two different subfolders, then XOWA will only use one, and ignore the other.

## Thumb directory

- All thumbs will go into the thumb directory
- Thumbs can be deleted, and they will be recreated.
- For nested files, thumbs will be created in a parallel directory
  - For example, the original file is in /xowa/wiki/my_wiki/orig/level_0/level_00/A.png.
  - The thumb file will be created in /xowa/wiki/my_wiki/thumb/level_0/level_00/A.png/30px.png

### XOWA

- Main page
- Screenshots
- Download XOWA
- Download wikis

### Getting started

- Requirements
- Installation
- Simple Wikipedia
- English Wikipedia
- Other Wikipedias

### Android

- Setup

### Help

- About
- Contents
- Media
- Feedback

### Blog

- Current

### Links

- Wikimedia dumps
- XOWA @ archive.org
- English Wikipedia

### Donate

- archive.org
- Wikipedia