Welcome to mirror list, hosted at ThFree Co, Russian Federation.

viewer_utils.js « lib « content_viewer « components « vue_shared « javascripts « assets « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b7fa73bc197bb872a23fa269f1dbe63b5e85c33f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { __ } from '~/locale';

const viewers = {
  image: {
    id: 'image',
    binary: true,
  },
  markdown: {
    id: 'markdown',
    previewTitle: __('Preview Markdown'),
  },
};

const fileNameViewers = {};
const fileExtensionViewers = {
  jpg: 'image',
  jpeg: 'image',
  gif: 'image',
  png: 'image',
  bmp: 'image',
  ico: 'image',
  md: 'markdown',
  markdown: 'markdown',
};

export function viewerInformationForPath(path) {
  if (!path) return null;
  const name = path.split('/').pop();
  const extension = name.includes('.') && name.split('.').pop();
  const viewerName = fileNameViewers[name] || fileExtensionViewers[extension];

  return viewers[viewerName];
}

export default viewers;