blob: fdd495861fc1b841bca2724b6237610ee6e9d6bf (
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
|
#include "../../plugins/Pipe.hpp"
#include "../../include/QuickMedia.hpp"
#include <string>
#include <iostream>
namespace QuickMedia {
PluginResult PipePage::submit(const SubmitArgs &args, std::vector<Tab>&) {
puts(!args.url.empty() ? args.url.c_str() : args.title.c_str());
program->set_pipe_selected_text(!args.url.empty() ? args.url : title);
return PluginResult::OK;
}
// static
void PipePage::load_body_items_from_stdin(BodyItems &items) {
std::string line;
while(std::getline(std::cin, line)) {
std::string name;
std::string filepath;
size_t split_index = line.find('|');
if(split_index == std::string::npos) {
name = std::move(line);
} else {
name = line.substr(0, split_index);
filepath = line.substr(split_index + 1);
}
auto body_item = BodyItem::create(std::move(name));
if(!filepath.empty()) {
body_item->thumbnail_url = std::move(filepath);
body_item->thumbnail_is_local = true;
}
items.push_back(std::move(body_item));
}
}
}
|