Skip to content

Commit

Permalink
how do you like this, Elon Musk?
Browse files Browse the repository at this point in the history
  • Loading branch information
folix-01 committed Jun 20, 2023
1 parent 70ed8e4 commit 6492db5
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 271 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
5.0.4 (unreleased)
------------------

- Nothing changed yet.
- Remove twitter feeds.
[folix-01]


5.0.3 (2023-06-13)
Expand Down
45 changes: 0 additions & 45 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,51 +164,6 @@ La struttura degli attachments è la seguente::

Se l'invio va a buon fine, viene tornata una risposta con `204`.

@twitter-feed
-------------

Endpoint per poter visualizzare una serie di tweet.

Per poterla utilizzare, bisogna creare un'app su Twitter e impostare il token Bearer dentro al registry Plone nella entry *design.plone.policy.twitter_token*.

Per fare la ricerca, utilizza l'endpoint `recent`_ che permette di visualizzare solo i tweet dell'ultima settimana.

.. _recent: https://developer.twitter.com/en/docs/twitter-api/tweets/search/introduction

Come parametri accetta i seguenti:

- **authors**: una lista di username tra cui ricercare gli ultimi Tweet.
- **max_results**: un numero tra 10 e 100.

Esempio di chiamata::

> curl -i -X GET http://localhost:8080/Plone/@twitter-feed?authors=foo&authors=bar -H 'Accept: application/json' -H 'Content-Type: application/json'

La risposta è una lista di tweet con le informazioni necessarie per essere renderizzati::

[
{
"author": {
"id": "12345678",
"name": "John Doe",
"profile_image_url": "https://pbs.twimg.com/profile_images/xxx/xxx_normal.jpg",
"username": "jdoe"
},
"id": "xxxxx",
"like_count": 1,
"reply_count": 0,
"retweet_count": 0,
"text": "stringa html"
},
...
]

Il campo `text` contiene già eventuali link ad hashtag, menzioni e link esterni dentro ad un tag <a/>.

**Per evitare troppe chiamate al servizio (c'è un limite di 500000 tweet al mese), c'è della cache: per ogni query
i risultati rimangono in cache per mezz'ora.**


Amministrazione trasparente
===========================

Expand Down
2 changes: 1 addition & 1 deletion src/design/plone/policy/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ class IDesignPlonePolicyLayer(IDefaultBrowserLayer):


class IDesignPlonePolicySettings(Interface):
twitter_token = schema.TextLine(title="Twitter Bearer token")
"""IDesignPlonePolicySettings interface"""
9 changes: 0 additions & 9 deletions src/design/plone/policy/profiles/to_1400/registry.xml

This file was deleted.

1 change: 0 additions & 1 deletion src/design/plone/policy/restapi/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@

<include package=".bandi_search_filters" />
<include package=".search_filters" />
<include package=".twitter_feed" />

</configure>
Empty file.
21 changes: 0 additions & 21 deletions src/design/plone/policy/restapi/twitter_feed/configure.zcml

This file was deleted.

179 changes: 0 additions & 179 deletions src/design/plone/policy/restapi/twitter_feed/get.py

This file was deleted.

33 changes: 19 additions & 14 deletions src/design/plone/policy/upgrades.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@


def update_profile(context, profile, run_dependencies=True):
context.runImportStepFromProfile(DEFAULT_PROFILE, profile, run_dependencies)
context.runImportStepFromProfile(
DEFAULT_PROFILE, profile, run_dependencies
)


def update_types(context):
Expand Down Expand Up @@ -63,7 +65,9 @@ def fix_field_name(blocks):
installOrReinstallProduct(api.portal.get(), "collective.volto.formsupport")
logger.info("Changing form block fields.")
i = 0
brains = api.content.find(object_provides="plone.restapi.behaviors.IBlocks")
brains = api.content.find(
object_provides="plone.restapi.behaviors.IBlocks"
)
tot = len(brains)
fixed_items = []
for brain in brains:
Expand Down Expand Up @@ -92,14 +96,7 @@ def to_1300(context):


def to_1400(context):
old = api.portal.get_registry_record(name="design.plone.policy.twitter_token")
context.runAllImportStepsFromProfile("profile-design.plone.policy:to_1400")
update_registry(context)

if old:
api.portal.set_registry_record(
"twitter_token", old, interface=IDesignPlonePolicySettings
)
pass


def to_1500(context):
Expand Down Expand Up @@ -173,7 +170,9 @@ def to_1910(context):
else:
new_sizes.append(size)
if "midi 300:65536" not in new_sizes:
new_sizes.insert(new_sizes.index("mini 200:65536") + 1, "midi 300:65536")
new_sizes.insert(
new_sizes.index("mini 200:65536") + 1, "midi 300:65536"
)
api.portal.set_registry_record("plone.allowed_sizes", new_sizes)


Expand Down Expand Up @@ -234,7 +233,9 @@ def fix_block(blocks):
blocks = value.get("blocks", {})
except AttributeError:
logger.warning(
"[RICHTEXT] - {} (not converted)".format(brain.getURL())
"[RICHTEXT] - {} (not converted)".format(
brain.getURL()
)
)
if blocks:
res = fix_block(blocks)
Expand Down Expand Up @@ -262,7 +263,9 @@ def update_folders(context, CHANGES=[], NEW_ITEMS=[]):
portal_name = portal.getId()
for item in CHANGES:
try:
folder = portal.restrictedTraverse("{}{}".format(portal_name, item))
folder = portal.restrictedTraverse(
"{}{}".format(portal_name, item)
)
old_title = folder.title
old_path = "/".join(folder.getPhysicalPath())
api.content.rename(obj=folder, new_id=CHANGES[item][1])
Expand All @@ -276,7 +279,9 @@ def update_folders(context, CHANGES=[], NEW_ITEMS=[]):
)
)
except KeyError:
logger.info("{} Impossibile modificare {}{}".format(RED, item, ENDC))
logger.info(
"{} Impossibile modificare {}{}".format(RED, item, ENDC)
)

for item in NEW_ITEMS:
folder = portal.restrictedTraverse("{}{}".format(portal_name, item[0]))
Expand Down

0 comments on commit 6492db5

Please sign in to comment.