-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-protocol.html
More file actions
166 lines (150 loc) · 5.97 KB
/
test-protocol.html
File metadata and controls
166 lines (150 loc) · 5.97 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sorcery Protocol Test</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
max-width: 800px;
margin: 50px auto;
padding: 20px;
line-height: 1.6;
}
h1 {
color: #333;
}
.test-section {
margin: 30px 0;
padding: 20px;
background: #f5f5f5;
border-radius: 8px;
}
a {
display: inline-block;
margin: 10px 0;
padding: 10px 15px;
background: #007bff;
color: white;
text-decoration: none;
border-radius: 4px;
transition: background 0.3s;
}
a:hover {
background: #0056b3;
}
code {
background: #e9ecef;
padding: 2px 6px;
border-radius: 3px;
font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
}
.info {
background: #d1ecf1;
border-left: 4px solid #0c5460;
padding: 15px;
margin: 20px 0;
}
button {
padding: 10px 15px;
background: #28a745;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
margin: 5px;
}
button:hover {
background: #218838;
}
.result {
margin-top: 10px;
padding: 10px;
background: #fff;
border: 1px solid #ddd;
border-radius: 4px;
min-height: 50px;
}
</style>
</head>
<body>
<h1>🔗 Sorcery Protocol Handler Test</h1>
<div class="info">
<strong>Note:</strong> The first time you click a link, your browser will ask for permission to open Sorcery.
Click "Allow" or "Open Sorcery" in the dialog.
</div>
<div class="test-section">
<h2>Test Links</h2>
<p>Click these links to test the protocol handler:</p>
<h3>macOS/Linux</h3>
<a href="srcuri:///etc/hosts@L1">Open /etc/hosts at line 1</a><br>
<a href="srcuri:///etc/hosts@L22">Open /etc/hosts at line 22</a><br>
<a href="srcuri:///tmp/test.txt@L42C10">Open /tmp/test.txt at line 42, column 10</a>
<h3>Your Project</h3>
<a href="srcuri://sorcery/README.md@L1">Open README.md at line 1</a><br>
<a href="srcuri://sorcery/src-tauri/src/main.rs@L50">Open main.rs at line 50</a><br>
<a href="srcuri://sorcery/DEVELOPMENT.md@L1">Open DEVELOPMENT.md</a>
<h3>Absolute Paths</h3>
<a href="srcuri:///Users/alice/apps/sorcery/README.md@L1">Open project README (absolute path)</a><br>
<a href="srcuri:///Users/alice/apps/sorcery/README.md@L50">Open project README at line 50 (absolute path)</a>
<h3>Any Mode</h3>
<a href="srcuri://any/sorcery/README.md@L1">Open README via any (workspace-leading)</a><br>
<a href="srcuri://any//etc/hosts@L1">Open /etc/hosts via any (absolute)</a>
</div>
<div class="test-section">
<h2>JavaScript Test</h2>
<p>Test programmatic protocol invocation:</p>
<button onclick="testProtocol('/etc/hosts:1')">Test /etc/hosts</button>
<button onclick="testProtocol('/tmp/test.txt:10')">Test /tmp/test.txt</button>
<button onclick="testProtocol('sorcery/README.md:1', true)">Test Workspace Link</button>
<button onclick="testProtocol('any/sorcery/README.md:1')">Test Any (workspace-leading)</button>
<button onclick="testProtocol('any//etc/hosts:1')">Test Any (absolute)</button>
<div class="result" id="result">
<em>Click a button above to test...</em>
</div>
</div>
<div class="test-section">
<h2>Manual Test</h2>
<p>Paste this directly in your browser's address bar:</p>
<code>srcuri:///etc/hosts@L1</code>
</div>
<div class="test-section">
<h2>Troubleshooting</h2>
<ul>
<li><strong>Nothing happens when I click:</strong> Make sure you've installed Sorcery to /Applications (run <code>make install</code>)</li>
<li><strong>Browser shows error:</strong> Check that the protocol is registered: <code>defaults read /Applications/Sorcery\ Desktop.app/Contents/Info CFBundleURLTypes</code></li>
<li><strong>Wrong app opens:</strong> Re-register: <code>make install-quick</code></li>
<li><strong>Permission denied:</strong> Allow the browser to open external apps in browser settings</li>
</ul>
</div>
<script>
function testProtocol(path, isWorkspace = false) {
const url = isWorkspace ? `srcuri://${path}` : `srcuri://${path}`;
const resultDiv = document.getElementById('result');
resultDiv.innerHTML = `
<strong>Testing:</strong> <code>${url}</code><br>
<em>Opening...</em>
`;
try {
window.location.href = url;
setTimeout(() => {
resultDiv.innerHTML = `
<strong>✓ Sent:</strong> <code>${url}</code><br>
<em>If your editor didn't open, check the troubleshooting section below.</em>
`;
}, 500);
} catch (error) {
resultDiv.innerHTML = `
<strong>✗ Error:</strong> ${error.message}<br>
<em style="color: red;">Failed to invoke protocol handler. Make sure Sorcery is installed.</em>
`;
}
}
// Log when page loads
console.log('Sorcery Protocol Test Page Loaded');
console.log('Platform:', navigator.platform);
console.log('User Agent:', navigator.userAgent);
</script>
</body>
</html>