<commit_before># -*- coding: utf-8 -*-
class BookmarksViewController < UITableViewController
  attr_accessor :entry
  include HBFav2::ApplicationSwitchNotification

  def viewDidLoad
    super
    @bookmarks = []

    self.navigationItem.title = entry.count.to_s
    view.backgroundColor = UIColor.whiteColor

    ## Set RefreshControl background (work around)
    frame = self.tableView.bounds
    frame.origin.y = -frame.size.height
    bgview = UIView.alloc.initWithFrame(frame)
    bgview.backgroundColor = '#e2e7ed'.uicolor
    self.tableView.insertSubview(bgview, atIndex: 0)

    @indicator = UIActivityIndicatorView.new.tap do |v|
      v.style = UIActivityIndicatorViewStyleGray
      v.startAnimating
    end
    view << @indicator

    loadBookmarks
  end

  def loadBookmarks
    query = BW::HTTP.get("http://b.hatena.ne.jp/entry/jsonlite/", {payload: {url: entry.link}}) do |response|
      @connection = nil

      if response.ok?
        autorelease_pool {
          json = BW::JSON.parse(response.body.to_str)
          if json and json['bookmarks'].present?
            @bookmarks = json['bookmarks'].collect do |dict|
              Bookmark.new(
                {
                  :title => entry.title,
                  :link  => entry.link,
                  :count => entry.count.to_s,
                  :eid   => json['eid'],
                  :user => {
                    :name => dict[:user]
                  },
                  :comment => dict[:comment],
                  :created_at => dict[:timestamp],
                  # 2005/02/10 20:55:55 => 2005-02-10T20:55:55+09:00
                  :datetime =>  dict[:timestamp].gsub(/\//, '-').gsub(/ /, 'T') + '+09:00'
                }
              )
            end
          else
            App.alert("ブックマークが全てプライベートモード、もしくはコメント非表示設定のエントリーです")
          end
        }
        view.reloadData
      else
        App.alert(response.error_message)
      end
      @indicator.stopAnimating
      ## Show "scrolls to bottom" button
      if (tableView.contentSize.height > tableView.frame.size.height)
        button = UIBarButtonItem.titled("下へ").tap do |btn|
          btn.action = "on_navigate"
          btn.target = self
        end
        self.navigationItem.setRightBarButtonItem(button, animated:true)<commit_msg>Fix error output<commit_after># -*- coding: utf-8 -*-
class BookmarksViewController < UITableViewController
  attr_accessor :entry
  include HBFav2::ApplicationSwitchNotification

  def viewDidLoad
    super
    @bookmarks = []

    self.navigationItem.title = entry.count.to_s
    view.backgroundColor = UIColor.whiteColor

    ## Set RefreshControl background (work around)
    frame = self.tableView.bounds
    frame.origin.y = -frame.size.height
    bgview = UIView.alloc.initWithFrame(frame)
    bgview.backgroundColor = '#e2e7ed'.uicolor
    self.tableView.insertSubview(bgview, atIndex: 0)

    @indicator = UIActivityIndicatorView.new.tap do |v|
      v.style = UIActivityIndicatorViewStyleGray
      v.startAnimating
    end
    view << @indicator

    loadBookmarks
  end

  def loadBookmarks
    query = BW::HTTP.get("http://b.hatena.ne.jp/entry/jsonlite/", {payload: {url: entry.link}}) do |response|
      @connection = nil

      if response.ok?
        autorelease_pool {
          json = BW::JSON.parse(response.body.to_str)
          if json and json['bookmarks'].present?
            @bookmarks = json['bookmarks'].collect do |dict|
              Bookmark.new(
                {
                  :title => entry.title,
                  :link  => entry.link,
                  :count => entry.count.to_s,
                  :eid   => json['eid'],
                  :user => {
                    :name => dict[:user]
                  },
                  :comment => dict[:comment],
                  :created_at => dict[:timestamp],
                  # 2005/02/10 20:55:55 => 2005-02-10T20:55:55+09:00
                  :datetime =>  dict[:timestamp].gsub(/\//, '-').gsub(/ /, 'T') + '+09:00'
                }
              )
            end
          else
            NSLog('private?')
            App.alert("ブックマークが全てプライベートモード、もしくはコメント非表示設定のエントリーです")
          end
        }
        view.reloadData
      else
        App.alert("通信エラー: " + response.status_code.to_s)
      end
      @indicator.stopAnimating
      ## Show "scrolls to bottom" button
      if (tableView.contentSize.height > tableView.frame.size.height)
        button = UIBarButtonItem.titled("下へ").tap do |btn|
          btn.action = "on_navigate"
          btn.target = self
        end
        self.navigationItem.setRightBarButtonItem(button, animated:true)
{'fraction_non_alphanumeric': 0.1182287188306105, 'fraction_numerical': 0.0176268271711092, 'mean_word_length': 1.908125, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 25, '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': '358857', 'n_tokens_mistral': 1513, 'n_tokens_neox': 1409, 'n_words': 247}