<commit_before>import {Post} from '../pages/gallery/gallery';
import * as URI from 'urijs';

export interface PostProvider {
  getPosts(offset?: number): Post[];
}

export class GelbooruService implements PostProvider {
  constructor(private siteAddress: string) {}

  getPosts(offset: number = 0): Post[] {
    let response = SAMPLE_DATA[this.siteAddress];

    if (!response) {
      // TODO: Provide an error message for unsupported site.
      return [];
    }

    let results = [];
    let counter = 0;
    for (let post of response) {
      let image = URI({
        protocol: 'http',
        hostname: this.siteAddress,
        path: `images/${post.directory}/${post.image}`,
      }).toString();

      let thumbnail = URI({
        protocol: 'http',
        hostname: this.siteAddress,
        path: `thumbnails/${post.directory}/thumbnail_${post.image}`,
      }).toString();

      results.push({
        image: image,
        thumbnail: thumbnail,
        sample: thumbnail,
        tags: post.tags.split(' '),
        index: counter,
      });

      counter += 1;
    }
<commit_msg>Properly Generate Gelbooru Sample Url<commit_after>import {Post} from '../pages/gallery/gallery';
import * as URI from 'urijs';

export interface PostProvider {
  getPosts(offset?: number): Post[];
}

export class GelbooruService implements PostProvider {
  constructor(private siteAddress: string) {}

  getPosts(offset: number = 0): Post[] {
    let response = SAMPLE_DATA[this.siteAddress];

    if (!response) {
      // TODO: Provide an error message for unsupported site.
      return [];
    }

    let results = [];
    let counter = 0;
    for (let post of response) {
      let image = URI({
        protocol: 'http',
        hostname: this.siteAddress,
        path: `images/${post.directory}/${post.image}`,
      }).toString();

      let sample;
      if (post.sample) {
        sample = URI({
          protocol: 'http',
          hostname: this.siteAddress,
          path: `samples/${post.directory}/sample_${post.image}`,
        }).toString();
      } else {
        sample = image;
      }


      let thumbnail = URI({
        protocol: 'http',
        hostname: this.siteAddress,
        path: `thumbnails/${post.directory}/thumbnail_${post.image}`,
      }).toString();

      results.push({
        image: image,
        thumbnail: thumbnail,
        sample: sample,
        tags: post.tags.split(' '),
        index: counter,
      });

      counter += 1;
    }

{'fraction_non_alphanumeric': 0.1392354124748491, 'fraction_numerical': 0.002414486921529175, 'mean_word_length': 2.3504043126684637, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3288026', 'n_tokens_mistral': 739, 'n_tokens_neox': 713, 'n_words': 188}