Commit d1ee7591 authored by Christian Hergert's avatar Christian Hergert

fpaste: remove fpaste plugin

This plugin has been broken in a couple different ways, and the
paste server API has completely changed. Instead of trying to
fix this (which requires a bunch), I'd rather just remove this.

If someone wants to make a new version that is well supported,
they can build it however the see fit.
parent caf8018a
......@@ -39,7 +39,6 @@ option('with_eslint', type: 'boolean')
option('with_file_search', type: 'boolean')
option('with_find_other_file', type: 'boolean')
option('with_flatpak', type: 'boolean')
option('with_fpaste', type: 'boolean')
option('with_gcc', type: 'boolean')
option('with_gdb', type: 'boolean')
option('with_gettext', type: 'boolean')
......
[Plugin]
Module=fpaste_plugin
Loader=python3
Name=Fedora Paste
Description=Paste code to fpaste.org
Authors=Christian Hergert <christian@hergert.me>
Copyright=Copyright © 2015 Christian Hergert
Depends=editor
Builtin=true
#!/usr/bin/env python3
#
# fpaste_plugin.py
#
# Copyright (C) 2015 Christian Hergert <chris@dronelabs.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import gi
gi.require_version('Gdk', '3.0')
gi.require_version('Gtk', '3.0')
gi.require_version('Ide', '1.0')
from gi.repository import Gio
from gi.repository import GLib
from gi.repository import GObject
from gi.repository import Gdk
from gi.repository import Gtk
from gi.repository import Ide
import json
import threading
import urllib.parse
import urllib.request
_ = Ide.gettext
USER_AGENT = 'gnome-builder-fpaste/0.1'
BASE_URL = 'https://paste.fedoraproject.org'
class FpasteEditorViewAddin(GObject.Object, Ide.EditorViewAddin):
def do_load(self, view):
self.view = view
action = Gio.SimpleAction(name='send-to-fpaste')
action.connect('activate', self.send_to_faste)
self.view.get_action_group('view').add_action(action)
def do_unload(self, view):
self.view.get_action_group('view').remove_action('send-to-fpaste')
self.view = None
def get_text(self):
buf = self.view.get_document()
if buf.get_has_selection():
# XXX: .get_selection_bounds() looks broken
begin = buf.get_iter_at_mark(buf.get_insert())
end = buf.get_iter_at_mark(buf.get_selection_bound())
else:
begin = buf.get_start_iter()
end = buf.get_end_iter()
return begin.get_slice(end)
def send_to_faste(self, action, param):
text = self.get_text()
self._send_to_fpaste(text)
def _send_to_fpaste(self, text, options=None):
if options is None:
options = {}
text = self.get_text()
params = urllib.parse.urlencode({
'paste_lang': options.get('language', ''),
'paste_data': text,
'api_submit': True,
'mode': 'json'
})
req = urllib.request.Request(BASE_URL,
data=params.encode(),
headers={'User-Agent': USER_AGENT})
Uploader(req).start()
class Uploader(threading.Thread):
def __init__(self, request):
super().__init__()
self.request = request
def run(self):
f = urllib.request.urlopen(self.request)
GLib.timeout_add(0, self.complete, f)
print("Got "+repr(f))
def complete(self, stream):
try:
response = json.loads(stream.read().decode())
result = response.get('result', {})
message = str(result)
dialog = Gtk.MessageDialog(buttons=Gtk.ButtonsType.CLOSE, text=message)
if 'id' in result:
uri = BASE_URL + '/' + str(result['id'] + '/')
if result.get('hash', None):
uri += str(result['hash']) + '/'
dialog.props.text = _("The following URL has been copied to the clipboard")
label = Gtk.LinkButton(visible=True, label=uri, uri=uri, margin=12)
Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD).set_text(uri, len(uri))
dialog.get_message_area().add(label)
dialog.run()
dialog.destroy()
except Exception as ex:
print(ex)
finally:
return False
<?xml version="1.0"?>
<interface>
<menu id="ide-source-view-popup-menu">
<section id="ide-source-view-popup-menu-selection-section">
<submenu id="ide-source-view-popup-menu-selection-submenu">
<section id="ide-source-view-popup-menu-selection-send-to-section">
<attribute name="after">ide-source-view-popup-menu-line-section</attribute>
<item>
<attribute name="label" translatable="yes">Send to Fpaste.org</attribute>
<attribute name="action">view.send-to-fpaste</attribute>
</item>
</section>
</submenu>
</section>
</menu>
</interface>
if get_option('with_fpaste')
fpaste_datadir = join_paths(plugindatadir, 'fpaste_plugin')
fpaste_dir = join_paths(plugindir, 'fpaste_plugin')
install_data('fpaste_plugin/__init__.py', install_dir: fpaste_dir)
install_subdir('fpaste_plugin/gtk', install_dir: fpaste_datadir)
configure_file(
input: 'fpaste.plugin',
output: 'fpaste.plugin',
configuration: configuration_data(),
install: true,
install_dir: plugindir,
)
endif
......@@ -29,7 +29,6 @@ subdir('eslint')
subdir('file-search')
subdir('find-other-file')
subdir('flatpak')
subdir('fpaste')
subdir('gcc')
subdir('gdb')
subdir('gettext')
......@@ -86,7 +85,6 @@ status += [
'File Search ........... : @0@'.format(get_option('with_file_search')),
'Find other file ....... : @0@'.format(get_option('with_find_other_file')),
'Flatpak ............... : @0@'.format(get_option('with_flatpak')),
'Fpaste ................ : @0@'.format(get_option('with_fpaste')),
'GCC ................... : @0@'.format(get_option('with_gcc')),
'GDB ................... : @0@'.format(get_option('with_gdb')),
'Gettext ............... : @0@'.format(get_option('with_gettext')),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment