Skip to content

Commit

Permalink
Merge pull request #181 from camarm-dev/dev
Browse files Browse the repository at this point in the history
Version 1.2.2 with patches for #179, #180
  • Loading branch information
camarm-dev authored Jun 15, 2024
2 parents 20602c8 + c3cf927 commit ec74e79
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ android {
applicationId "com.camarm.remede"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 121
versionName '1.2.1 — Brown Sheep, revison 1'
versionCode 122
versionName '1.2.2 — Brown Sheep, revison 2'
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
aaptOptions {
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
Expand Down
4 changes: 2 additions & 2 deletions app/android/app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 121,
"versionName": "1.2.1 — Brown Sheep, revison 1",
"versionCode": 122,
"versionName": "1.2.2 — Brown Sheep, revison 2",
"outputFile": "app-release.apk"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,

// // Handle widget clicks
Intent intent = new Intent(context, RemedeSearchbarWidget.class).setAction(CLICK_ACTION);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
views.setOnClickPendingIntent(R.id.imageView, pendingIntent);

// Instruct the widget manager to update the widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,

// Handle clicks
Intent intent = new Intent(context, RemedeWordOfDayWidget.class).setAction(CLICK_ACTION).setData(Uri.parse(context.getResources().getString(R.string.custom_url_scheme) + "://dictionnaire/" + word));
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
views.setOnClickPendingIntent(R.id.container, pendingIntent);

// Instruct the widget manager to update the widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
android:layout_marginBottom="8dp"
android:layout_marginBottom="3dp"
android:contentDescription="@string/wodwidget_phoneme"
android:fontFamily="@font/ibm_plex_serif_bold"
android:text="@string/wodwidget_phoneme"
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "remede",
"private": true,
"version": "1.2.1",
"version": "1.2.2",
"type": "module",
"license": "Cecill V2.1",
"author": {
Expand Down
Binary file modified builds/latest/remede.apk
Binary file not shown.
4 changes: 2 additions & 2 deletions docs/download.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h1 class="title no-mg is-large has-text-dark">
<i class="fas fa-arrow-right has-text-primary"></i>
<span class="has-text-primary">Le meilleur dictionnaire mobile</span>
</h1>
<p class="has-text-grey">Choisis ta platforme ci-dessous et profite du meilleur dictionnaire mobile dès maintenant !</p>
<p class="has-text-grey">Choisis ta plateforme ci-dessous et profite du meilleur dictionnaire mobile dès maintenant !</p>
<br>
<a href="/" class="button is-primary">Découvrir Remède</a>
</div>
Expand Down Expand Up @@ -127,7 +127,7 @@ <h1 class="title no-mg is-large has-text-dark">
<tr>
<td>Android</td>
<td><span class="tag is-success">APK</span></td>
<td><span class="tag">1.2.1 </span></td>
<td><span class="tag">1.2.2 </span></td>
<td>15/06/24</td>
<td>5.5MB</td>
<td><a class="button is-small" href="https://api-remede.camarm.fr/release/apk" download="remede.apk">Download</a></td>
Expand Down
24 changes: 19 additions & 5 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import os
import sqlite3
import threading
from enum import Enum
from hashlib import md5

Expand All @@ -14,7 +15,8 @@
from fastapi.responses import FileResponse
from starlette.middleware.cors import CORSMiddleware

version = "1.2.1"
lock = threading.Lock()
version = "1.2.3"
app = FastAPI(title='Remède', description='Un dictionnaire libre.', version=version)
app.add_middleware(
CORSMiddleware,
Expand All @@ -40,6 +42,7 @@ def in_json(response: str | list):


def fetch_random_word():
lock.acquire(True)
return cursor.execute("SELECT word FROM dictionary ORDER BY RANDOM() LIMIT 1").fetchone()[0]


Expand All @@ -49,15 +52,18 @@ def fetch_remede_word_of_day():
if today != WORD_OF_DAY['date']:
WORD_OF_DAY['date'] = today
WORD_OF_DAY['word'] = fetch_random_word()
lock.release()
return WORD_OF_DAY['word']


def fetch_remede_doc(word: str):
lock.acquire(True)
response = cursor.execute(f"SELECT document FROM dictionary WHERE word = '{word}'").fetchone()
return response[0] if response else {'message': 'Mot non trouvé'}


def fetch_autocomplete(query: str, limit: bool = False):
lock.acquire(True)
if limit:
response = cursor.execute(f"SELECT word FROM wordlist WHERE indexed LIKE '{query}%' ORDER BY word ASC LIMIT 5").fetchall()
else:
Expand Down Expand Up @@ -145,15 +151,19 @@ def get_word_document(word: str):
"""
Renvoie le document Remède du mot `word`
"""
return json.loads(fetch_remede_doc(word.replace("'", "''")))
document = fetch_remede_doc(word.replace("'", "''"))
lock.release()
return json.loads(document)


@app.get('/random')
def get_random_word_document():
"""
Renvoie un mot au hasard
"""
return in_json(fetch_random_word())
word = fetch_random_word()
lock.release()
return in_json(word)


@app.get('/word-of-day')
Expand All @@ -170,7 +180,9 @@ def get_autocomplete(query: str):
Renvoie les 6 premiers mots commençant par `query`, n'est pas sensible à la casse et aux accents !
"""
safe_query = sanitize_query(query)
return in_json(fetch_autocomplete(safe_query, True))
results = fetch_autocomplete(safe_query, True)
lock.release()
return in_json(results)


@app.get('/search/{query}')
Expand All @@ -179,7 +191,9 @@ def get_search_results(query: str):
Renvoie les mots commençant par `query`, n'est pas sensible à la casse et aux accents !
"""
safe_query = sanitize_query(query)
return in_json(fetch_autocomplete(safe_query))
results = fetch_autocomplete(safe_query)
lock.release()
return in_json(results)


@app.get('/ask-new-word/{query}')
Expand Down

0 comments on commit ec74e79

Please sign in to comment.