<commit_before># frozen_string_literal: true

module Lokka
  module AmazonAssociate
    class HtmlFormatter
      include CacheControllable

      attr_reader :item_id

      def initialize(item_id)
        @item_id = item_id
        @kind = :html
        wirite_or_touch_cache unless cache_alive?
      end

      def item
        @item ||= Item.new(@item_id)
      end

      def format
        <<~HTML
          <!DOCTYPE html>
          <html lang="ja">
            <head>
            <title><%= item.title %></title>
            <style>
              .amazon {
                display: flex;
                align-items: start;
                margin: 0 auto;
                max-height: 320px;
                background: #fff;
                color: #000;
                font-size: 16px;
                line-height: 150%;
                border-radius: 5px;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
              }
              .amazon a {
                text-shadow: none;
              }
              .amazon-image, .amazon-content {
                margin: 2.5em 1em;
              }
              .amazon-image {
                display: flex;
                align-items: center;
                justify-content: center;
                min-width: 250px;
              }
              .amazon-image img {
                filter: brightness(100%);
                max-height: 200px;
                max-width: 200px;
              }
              .amazon-image img:hover {
                filter: brightness(105%);
              }
              .amazon-content {
                margin-right: 2em;
              }
              .amazon-content .item-title {
                font-size: 1.2em;
                font-weight: bold;
                margin: 0 auto;
              }
              .amazon-content .item-title:before {
                content: none;
                margin: 0;
              }
              .amazon-content .item-meta, .amazon-content .item-price {
                margin: .75em auto;
              }
              .amazon-content .item-meta span:not(:last-child):after {
                content: '/';
                margin-left: .5em;
              }
              .amazon-content .to-amazon a {
                display: block;
                width: 328px;
                height: 52px;<commit_msg>Consider the case Amazon item has too long title<commit_after># frozen_string_literal: true

module Lokka
  module AmazonAssociate
    class HtmlFormatter
      include CacheControllable

      attr_reader :item_id

      def initialize(item_id)
        @item_id = item_id
        @kind = :html
        wirite_or_touch_cache unless cache_alive?
      end

      def item
        @item ||= Item.new(@item_id)
      end

      def format
        <<~HTML
          <!DOCTYPE html>
          <html lang="ja">
            <head>
            <title><%= item.title %></title>
            <style>
              .amazon {
                display: flex;
                align-items: start;
                margin: 0 auto;
                max-height: 320px;
                background: #fff;
                color: #000;
                font-size: 16px;
                line-height: 150%;
                border-radius: 5px;
                -moz-border-radius: 5px;
                -webkit-border-radius: 5px;
              }
              .amazon a {
                text-shadow: none;
              }
              .amazon-image, .amazon-content {
                margin: 2.5em 1em;
              }
              .amazon-image {
                display: flex;
                align-items: center;
                justify-content: center;
                min-width: 250px;
              }
              .amazon-image img {
                filter: brightness(100%);
                max-height: 200px;
                max-width: 200px;
              }
              .amazon-image img:hover {
                filter: brightness(105%);
              }
              .amazon-content {
                margin-right: 2em;
              }
              .amazon-content .item-title {
                font-size: 1.2em;
                font-weight: bold;
                margin: 0 auto;
                display: -webkit-box;
                text-overflow: ellipsis;
                overflow: hidden;
                -webkit-box-orient: vertical;
                -webkit-line-clamp: 2;
              }
              .amazon-content .item-title:before {
                content: none;
                margin: 0;
              }
              .amazon-content .item-meta, .amazon-content .item-price {
                margin: .75em auto;
              }
              .amazon-content .item-meta span:not(:last-child):after {
                content: '/';
                margin-left: .5em;
              }
              .amazon-content .to-amazon a {
                display: block;
                width: 328px;
                height: 52px;
{'fraction_non_alphanumeric': 0.09258148370325935, 'fraction_numerical': 0.01859628074385123, 'mean_word_length': 0.9523809523809523, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 17, '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': '4157467', 'n_tokens_mistral': 1429, 'n_tokens_neox': 1249, 'n_words': 285}