Speakr is a personal, self-hosted web application designed for transcribing audio recordings
Python
added inbox and fav
Murtaza Nasiraf06c359dbbf
diff --git a/app.py b/app.pyindex 8eb86bba..534e928d 100644--- a/app.py+++ b/app.py@@ -101,6 +101,8 @@ class Recording(db.Model):meeting_date = db.Column(db.Date, nullable=True) # <-- ADDED: Meeting Date fieldfile_size = db.Column(db.Integer) # Store file size in bytesoriginal_filename = db.Column(db.String(500), nullable=True) # Store the original uploaded filename+ is_inbox = db.Column(db.Boolean, default=True) # New recordings are marked as inbox by default+ is_highlighted = db.Column(db.Boolean, default=False) # Recordings can be highlighted by the userdef to_dict(self):return {@@ -117,7 +119,9 @@ class Recording(db.Model):'meeting_date': self.meeting_date.isoformat() if self.meeting_date else None, # <-- ADDED: Include meeting_date'file_size': self.file_size,'original_filename': self.original_filename, # <-- ADDED: Include original filename- 'user_id': self.user_id+ 'user_id': self.user_id,+ 'is_inbox': self.is_inbox,+ 'is_highlighted': self.is_highlighted}# --- Forms for Authentication ---@@ -144,8 +148,42 @@ class LoginForm(FlaskForm):remember = BooleanField('Remember Me')submit = SubmitField('Login')+# Function to check and add columns if they don't exist+def add_column_if_not_exists(engine, table_name, column_name, column_type):+ """Add a column to a table if it doesn't exist."""+ from sqlalchemy import text++ try:+ # Check if column exists+ with engine.connect() as conn:+ # For SQLite, we can query the pragma table_info using text()+ result = conn.execute(text(f"PRAGMA table_info({table_name})"))+ columns = [row[1] for row in result]++ if column_name not in columns:+ app.logger.info(f"Adding column {column_name} to {table_name}")+ conn.execute(text(f"ALTER TABLE {table_name} ADD COLUMN {column_name} {column_type}"))+ return True+ return False+ except Exception as e:+ app.logger.error(f"Error checking/adding column {column_name} to {table_name}: {e}")+ return False+with app.app_context():db.create_all()++ # Check and add new columns if they don't exist+ engine = db.engine+ try:+ # Add is_inbox column with default value of 1 (True)+ if add_column_if_not_exists(engine, 'recording', 'is_inbox', 'BOOLEAN DEFAULT 1'):+ app.logger.info("Added is_inbox column to recording table")++ # Add is_highlighted column with default value of 0 (False)+ if add_column_if_not_exists(engine, 'recording', 'is_highlighted', 'BOOLEAN DEFAULT 0'):+ app.logger.info("Added is_highlighted column to recording table")+ except Exception as e:+ app.logger.error(f"Error during database migration: {e}")# --- API client setup for OpenRouter ---# Use environment variables from .env@@ -769,6 +807,8 @@ def save_metadata():if 'participants' in data: recording.participants = data['participants']if 'notes' in data: recording.notes = data['notes']if 'summary' in data: recording.summary = data['summary'] # <-- ADDED: Allow saving edited summary+ if 'is_inbox' in data: recording.is_inbox = data['is_inbox']+ if 'is_highlighted' in data: recording.is_highlighted = data['is_highlighted']if 'meeting_date' in data:try:# Attempt to parse date string (e.g., "YYYY-MM-DD")@@ -791,6 +831,52 @@ def save_metadata():app.logger.error(f"Error saving metadata for recording {recording_id}: {e}")return jsonify({'error': str(e)}), 500+# Toggle inbox status endpoint[email protected]('/recording/<int:recording_id>/toggle_inbox', methods=['POST'])+@login_required+def toggle_inbox(recording_id):+ try:+ recording = db.session.get(Recording, recording_id)+ if not recording:+ return jsonify({'error': 'Recording not found'}), 404++ # Check if the recording belongs to the current user+ if recording.user_id and recording.user_id != current_user.id:+ return jsonify({'error': 'You do not have permission to modify this recording'}), 403++ # Toggle the inbox status+ recording.is_inbox = not recording.is_inbox+ db.session.commit()++ return jsonify({'success': True, 'is_inbox': recording.is_inbox})+ except Exception as e:+ db.session.rollback()+ app.logger.error(f"Error toggling inbox status for recording {recording_id}: {e}")+ return jsonify({'error': str(e)}), 500++# Toggle highlighted status endpoint[email protected]('/recording/<int:recording_id>/toggle_highlight', methods=['POST'])+@login_required+def toggle_highlight(recording_id):+ try:+ recording = db.session.get(Recording, recording_id)+ if not recording:+ return jsonify({'error': 'Recording not found'}), 404++ # Check if the recording belongs to the current user+ if recording.user_id and recording.user_id != current_user.id:+ return jsonify({'error': 'You do not have permission to modify this recording'}), 403++ # Toggle the highlighted status+ recording.is_highlighted = not recording.is_highlighted+ db.session.commit()++ return jsonify({'success': True, 'is_highlighted': recording.is_highlighted})+ except Exception as e:+ db.session.rollback()+ app.logger.error(f"Error toggling highlighted status for recording {recording_id}: {e}")+ return jsonify({'error': str(e)}), 500+@app.route('/upload', methods=['POST'])@login_requireddiff --git a/templates/index.html b/templates/index.htmlindex e4026883..4a69e794 100644--- a/templates/index.html+++ b/templates/index.html@@ -576,6 +576,12 @@<div class="flex items-center overflow-hidden mr-2"><i class="fas fa-file-audio text-[var(--text-accent)] mr-2 flex-shrink-0"></i><span class="text-sm font-medium truncate" :title="recording.title || 'Loading title...'">${ recording.title || '(Processing...)' }</span>+ <span v-if="recording.is_inbox" class="ml-1 text-blue-500" title="Inbox">+ <i class="fas fa-inbox text-xs"></i>+ </span>+ <span v-if="recording.is_highlighted" class="ml-1 text-yellow-500" title="Highlighted">+ <i class="fas fa-star text-xs"></i>+ </span></div><div class="flex space-x-2 flex-shrink-0 items-center"><span v-if="recording.status === 'PROCESSING'" class="text-xs text-[var(--text-info-strong)] italic flex items-center" title="Transcribing...">@@ -610,7 +616,15 @@<div v-if="selectedRecording" class="flex-grow flex flex-col"><div class="flex flex-col sm:flex-row justify-between items-start mb-4 border-b border-[var(--border-primary)] pb-4"><div class="mb-3 sm:mb-0 max-w-lg">- <h3 class="text-2xl font-semibold text-[var(--text-primary)]">${ selectedRecording.title || 'Loading...' }</h3>+ <h3 class="text-2xl font-semibold text-[var(--text-primary)] flex items-center">+ ${ selectedRecording.title || 'Loading...' }+ <span v-if="selectedRecording.is_inbox" class="ml-2 text-blue-500" title="Inbox">+ <i class="fas fa-inbox"></i>+ </span>+ <span v-if="selectedRecording.is_highlighted" class="ml-2 text-yellow-500" title="Highlighted">+ <i class="fas fa-star"></i>+ </span>+ </h3><p class="text-sm text-[var(--text-muted)] mt-1"><!-- Display Meeting Date with edit functionality --><span>@@ -640,6 +654,14 @@<!-- Removed separate Status Badge span --></div><div class="flex space-x-2 flex-shrink-0">+ <button @click="toggleInbox(selectedRecording)" class="px-3 py-1.5 rounded-md text-sm shadow-sm"+ :class="selectedRecording.is_inbox ? 'bg-blue-500 text-white hover:bg-blue-600' : 'bg-gray-200 text-gray-700 hover:bg-gray-300'">+ <i class="fas fa-inbox mr-1"></i> ${selectedRecording.is_inbox ? 'Mark as Read' : 'Move to Inbox'}+ </button>+ <button @click="toggleHighlight(selectedRecording)" class="px-3 py-1.5 rounded-md text-sm shadow-sm"+ :class="selectedRecording.is_highlighted ? 'bg-yellow-500 text-white hover:bg-yellow-600' : 'bg-gray-200 text-gray-700 hover:bg-gray-300'">+ <i class="fas fa-star mr-1"></i> ${selectedRecording.is_highlighted ? 'Remove Highlight' : 'Highlight'}+ </button><button @click="editRecording(selectedRecording)" class="px-3 py-1.5 bg-[var(--bg-button)] text-[var(--text-button)] rounded-md hover:bg-[var(--bg-button-hover)] text-sm shadow-sm"><i class="fas fa-edit mr-1"></i> Edit Details</button>@@ -1411,6 +1433,64 @@// AutoSave removed in favor of explicit save in modal// const autoSave = () => { ... };+ // Toggle inbox status+ const toggleInbox = async (recording) => {+ if (!recording || !recording.id) return;++ try {+ const response = await fetch(`/recording/${recording.id}/toggle_inbox`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' }+ });++ const data = await response.json();+ if (!response.ok) throw new Error(data.error || 'Failed to toggle inbox status');++ // Update the recording in the UI+ recording.is_inbox = data.is_inbox;++ // Update in the recordings list+ const index = recordings.value.findIndex(r => r.id === recording.id);+ if (index !== -1) {+ recordings.value[index].is_inbox = data.is_inbox;+ }++ showToast(`Recording ${data.is_inbox ? 'moved to inbox' : 'marked as read'}`);+ } catch (error) {+ console.error('Toggle Inbox Error:', error);+ setGlobalError(`Failed to toggle inbox status: ${error.message}`);+ }+ };++ // Toggle highlighted status+ const toggleHighlight = async (recording) => {+ if (!recording || !recording.id) return;++ try {+ const response = await fetch(`/recording/${recording.id}/toggle_highlight`, {+ method: 'POST',+ headers: { 'Content-Type': 'application/json' }+ });++ const data = await response.json();+ if (!response.ok) throw new Error(data.error || 'Failed to toggle highlighted status');++ // Update the recording in the UI+ recording.is_highlighted = data.is_highlighted;++ // Update in the recordings list+ const index = recordings.value.findIndex(r => r.id === recording.id);+ if (index !== -1) {+ recordings.value[index].is_highlighted = data.is_highlighted;+ }++ showToast(`Recording ${data.is_highlighted ? 'highlighted' : 'unhighlighted'}`);+ } catch (error) {+ console.error('Toggle Highlight Error:', error);+ setGlobalError(`Failed to toggle highlighted status: ${error.message}`);+ }+ };+const saveMetadata = async (recordingDataToSave) => {globalError.value = null;if (!recordingDataToSave || !recordingDataToSave.id) return null;@@ -1942,6 +2022,8 @@formatDisplayDate, // <-- ADDED: Expose date formatting functiontoggleDarkMode, // <-- Added toggleDarkModetoggleSidebar, isSidebarCollapsed, // <-- Added sidebar state and function+ // Inbox and Highlight methods+ toggleInbox, toggleHighlight,// Inline editing methodstoggleEditParticipants, toggleEditMeetingDate, toggleEditSummary, toggleEditNotes, saveInlineEdit,// Chat Methods