GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Coding-iOS/Coding_iOS/Models/CodeFile.m at master · coding/Coding-iOS

Expand file tree

/

CodeFile.m

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
112 lines (99 loc) · 2.95 KB
/

CodeFile.m

Copy path

File metadata and controls

executable file
·
112 lines (99 loc) · 2.95 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
// CodeFile.m
// Coding_iOS
//
// Created by 王 原闯 on 14/10/29.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "CodeFile.h"
@implementation CodeFile
+ (CodeFile *)codeFileWithRef:(NSString *)ref andPath:(NSString *)path{
CodeFile *codeFile = [[CodeFile alloc] init];
codeFile.ref = ref;
codeFile.path = path;
return codeFile;
}
+ (CodeFile *)codeFileWithMDPreview:(NSString *)md_html{
CodeFile *codeFile = [self codeFileWithRef:@"" andPath:@"README"];
CodeFile_RealFile *file = [CodeFile_RealFile new];
file.mode = @"file";
file.lang = @"markdown";
file.preview = md_html;
codeFile.file = file;
return codeFile;
}
+ (CodeFile *)codeFileToCommitWithRef:(NSString *)ref andPath:(NSString *)path name:(NSString *)name data:(NSString *)data message:(NSString *)message headCommit:(Commit *)headCommit{
CodeFile *codeFile = [self codeFileWithRef:ref andPath:path];
codeFile.editName = name;
codeFile.editData = data;
codeFile.editMessage = message;
codeFile.headCommit = headCommit;
return codeFile;
}
+ (CodeFile *)codeFileWithLocalURL:(NSURL *)localURL{
CodeFile *codeFile = [self new];
CodeFile_RealFile *file = [CodeFile_RealFile new];
file.mode = @"file";
NSStringEncoding enc;
file.data = [NSString stringWithContentsOfURL:localURL usedEncoding:&enc error:nil];
file.lang = localURL.ea_lang ?: @"";
codeFile.file = file;
return codeFile;
}
- (NSString *)path{
if (!_path) {
_path = @"";
}
return _path;
}
- (NSString *)ref{
if (!_ref) {
_ref = @"master";
}
return _ref;
}
- (NSString *)editData{
if (!_editData) {
_editData = _file.data.copy;
}
return _editData;
}
- (NSString *)editName{
if (!_editName) {
_editName = _file.name.copy;
}
return _editName;
}
- (NSString *)editMessage{
if (!_editMessage) {
_editMessage = [NSString stringWithFormat:@"update %@", _path];
}
return _editMessage;
}
- (NSDictionary *)toEditParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"content"] = self.editData;
params[@"message"] = self.editMessage;
params[@"lastCommitSha"] = self.headCommit.commitId;
return params;
}
- (NSDictionary *)toDeleteParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"message"] = [NSString stringWithFormat:@"delete: %@", self.file.name];
params[@"lastCommitSha"] = self.headCommit.commitId;
return params;
}
- (NSDictionary *)toCreateParams{
NSMutableDictionary *params = @{}.mutableCopy;
params[@"title"] = self.editName;
params[@"content"] = self.editData ?: @"";
params[@"message"] = self.editMessage;
params[@"lastCommitSha"] = self.headCommit.commitId ?: @"";
return params;
}
@end
@implementation CodeFile_RealFile
- (void)setPreview:(NSString *)preview{
_preview = [preview stringByReplacingOccurrencesOfString:@"{{CodingUrl}}" withString:@""];
}
@end
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.