<commit_before># encoding: utf-8
# Feeds

before '/feed*' do
	authorize_basic! :user
	content_type :json, 'charset' => 'utf-8'
end

get '/feed' do
	Feed.all(:user => @user).to_json
end

get '/feed/:id', '/folder/*/feed/:id' do
	Feed.first(:user => @user, :id => params[:id]).to_json
end

get '/feed/:id/item' do |id|
	options = prepare_item_search(params)
	Feed.first(:user => @user, :id => id).items(options).to_json
end

post '/feed' do
	params[:folder] = 'Feeds' if params[:folder].nil? or params[:folder].empty?
	folder = Folder.first_or_create(:user => @user, :title => params[:folder])

	feed = Feed.new(
		:user => @user,
		:title => params[:url],
		:url => params[:url]
	)<commit_msg>Force feed titles to 100 characters<commit_after># encoding: utf-8
# Feeds

before '/feed*' do
	authorize_basic! :user
	content_type :json, 'charset' => 'utf-8'
end

get '/feed' do
	Feed.all(:user => @user).to_json
end

get '/feed/:id', '/folder/*/feed/:id' do
	Feed.first(:user => @user, :id => params[:id]).to_json
end

get '/feed/:id/item' do |id|
	options = prepare_item_search(params)
	Feed.first(:user => @user, :id => id).items(options).to_json
end

post '/feed' do
	params[:folder] = 'Feeds' if params[:folder].nil? or params[:folder].empty?
	folder = Folder.first_or_create(:user => @user, :title => params[:folder])

	feed = Feed.new(
		:user => @user,
		:title => params[:url][0..99],
		:url => params[:url]
	)
{'fraction_non_alphanumeric': 0.20665251238499646, 'fraction_numerical': 0.007077140835102618, 'mean_word_length': 4.48062015503876, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5066360', 'n_tokens_mistral': 550, 'n_tokens_neox': 538, 'n_words': 129}